[7.6.0] Webpack Compilation Error
See original GitHub issueCurrent 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 write require('../../../../my_dep')
in my test files.
Desired behavior
I have custom babel.config.json
, which helped to properly locate files.
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
],
"plugins": [
[
"module-resolver",
{
"root": [
"./"
],
"alias": {
"framework": "./framework"
}
}
]
]
}
Test code to reproduce
- Place a helper
my_utils.js
file in root of your project, that will return any code. - Have a test file placed in some sub-foldered structure, like
./tests/sub1/sub2/testfile.js
,require
-ing that helper file:
const utils = require('my_utils');
....
// any test code
Try to run that test file.
Versions
Windows 10 Cypress 7.6.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to get more detail than 'Webpack Compilation Error' with ...
Whenever there is an error inside one of my imported modules, all I get from Cypress is the message Error: Webpack Compilation Error...
Read more >Changelog - Cypress Documentation
Compile errors are now surfaced in the command log during tests for Angular and Next projects. Fixes #23219. The error "Automatic publicPath is...
Read more >webpack/webpack - Gitter
I'm running into an issue where webpack is placing some node_modules before the core-js modules and it ends up causing errors in IE11....
Read more >@faker-js/faker - npm
Generate massive amounts of fake contextual data. Latest version: 7.6.0, last published: 3 months ago. Start using @faker-js/faker in your ...
Read more >Firebase JavaScript SDK Release Notes - Google
Fixed some typings issues that caused compile errors for TypeScript users. ... an IndexedDB bug in Safari (https://bugs.webkit.org/show_bug.cgi?id=226547).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
js
files are now going through the Webpack compiler (or were they doing that already before?), and there is no way to turn it off.So, in order to make the setup I’ve presented above work again, I had to do these steps:
@cypress/webpack-preprocessor
cypress/plugins/index.js
:After these steps, my dependencies are back again, BUT I have to rewrite my tests to be ES6-compatible now!
Simply because
is not the same as
in Webpack world.
We have ~1000 test files to refactor now, or just stick to 7.5.0.
anyway, the easiest way to fix that was to add my “mappings” to the
browser
field in mypackage.json