-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[7.6.0] Webpack Compilation Error #17158
Comments
We have a very similar setup (we use Babel's module resolver to get rid of long relative paths) and are also unable to upgrade to 7.6.0 for the same reasons. |
I did some investigation on this issue, and it looks like the way our test files are processed is changed in 7.6.0. All of So, in order to make the setup I've presented above work again, I had to do these steps:
const webpackPreprocessor = require('@cypress/webpack-preprocessor');
module.exports = (on, config) => {
const options = webpackPreprocessor.defaultOptions;
Object.assign(options.webpackOptions, {
resolve: {
modules: [
'node_modules',
path.resolve(__dirname, '../../')
]
}
});
on('file:preprocessor', webpackPreprocessor(options));
}); After these steps, my dependencies are back again, BUT I have to rewrite my tests to be ES6-compatible now! Simply because // this code used to work before 7.6.0, since it was pure NodeJS processed
const dep = require('my_dep'); is not the same as // this is how code needs to be converted to work in 7.6.0, as now all of js files go through Webpack
import dep from 'my_dep'; in Webpack world. We have ~1000 test files to refactor now, or just stick to 7.5.0. |
My guess would be that the change was introduced in this PR: #15611 This wasn't intended to introduce breaking changes, so any ways that your tests are running differently was unintended.
I wasn't able to reproduce it from the information given alone. |
@jennifer-shehane Here is what my output looks like
My ...
"dependencies": {
"@babel/core": "7.14.6",
"@babel/eslint-parser": "7.14.7",
"@babel/preset-env": "7.14.7",
"babel-plugin-module-resolver": "4.1.0",
"cypress": "7.7.0",
"cypress-ntlm-auth": "3.2.3",
"eslint": "7.30.0",
"eslint-plugin-cypress": "2.11.3",
"eslint-plugin-sonarjs": "0.9.1"
},
"devDependencies": {
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"lint-staged": "11.0.0"
}
... And I have no plugins. |
@jennifer-shehane any progress on this issue? I've just tried with the latest Cypress 8.2.0, and the problem is still there. |
anyway, the easiest way to fix that was to add my "mappings" to the "browser": {
"framework/selectors": "./framework/selectors.js"
} |
Current behavior
After upgrading to Cypress 7.6.0 from 7.5.0, my tests can't run anymore, failing to locate files I'm
require
-ing in my tests. I don't use absolute path, but relative to the project root, so I don't have to writerequire('../../../../my_dep')
in my test files.Desired behavior
I have custom
babel.config.json
, which helped to properly locate files.Test code to reproduce
my_utils.js
file in root of your project, that will return any code../tests/sub1/sub2/testfile.js
,require
-ing that helper file:Try to run that test file.
Versions
Windows 10
Cypress 7.6.0
The text was updated successfully, but these errors were encountered: