cypress: 5.4.0 Regression: Webpack Compilation Error when browserslist is present in project root
Current behavior
I get the error when trying to run tests through the Runner:
Error: Webpack Compilation Error
./cypress/integration/main/login-page.test.js
Module build failed (from C:/Users/user/AppData/Local/Cypress/Cache/5.4.0/Cypress/resources/app/packages/server/node_modules/babel-loader/lib/index.js):
C:\Users\user\IdeaProjects\admin\project\project-ui\browserslist:1
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
^
SyntaxError: Invalid or unexpected token
Desired behavior
The error does not occur.
Test code to reproduce
Cypress update to version 5.4.0
Additionally, what I did to fix the problem:
- I deleted the cache from the location: C:\Users\user\AppData\Local\Cypress\Cache
- Deleted from the .node_modules directory the directory from cypress and babel-loader.
- I reinstalled cypress@5.4.0
Versions
Windows 10 64bit Browser: Chrome 86, FF 81, Electron 85, Edge86
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 10
- Comments: 20 (5 by maintainers)
@jennifer-shehane - please add the easiest workaround, rename
browserslistto.browserslistrc. According to the Angular docs, this renaming is actually applied when performing an upgrade to Angular 10, so this is the preferred filename from Angular.TLDR: Just delete the browserslist file.
If you take a look inside the browserslist file, there is a link to an external website. There, it states that Cypress will, upon running, try to locate an explicit definition of browserslist from the user. It will try to locate said definition from a variety of sources, failing which it will fall back on a default specification.
My guess is that this browserslist file we have (that was located by Cypress) is invalid because its format is incorrect. This I inferred.
My fix to delete this browserslist file hinges on the fact that Cypress will fall back on its own set of (valid) specifications if it fails to obtain a definition from the user. It appears to work.