Webpack Compilation Error when module is not imported
See original GitHub issueCurrent behavior
Cypress throws Webpack Compilation Error
when running following test file
const { fakeServer } = require("cypress/types/sinon")
describe('example to-do app', () => {
it.only('displays two todo items by default', () => {
fs.readFile("fileDoesn'tExist.js");
});
});
Error: Webpack Compilation Error
./cypress/integration/1-getting-started/todo.spec.js
Module not found: Error: Can't resolve 'cypress/types/sinon' in '/home/amit/temp/cytorus_code/test-repository/test/cypress/integration/1-getting-started'
resolve 'cypress/types/sinon' in '/home/amit/temp/cytorus_code/test-repository/test/cypress/integration/1-getting-started'
Parsed request is a module
using description file: /home/amit/temp/cytorus_code/test-repository/package.json (relative path: ./test/cypress/integration/1-getting-started)
Field 'browser' doesn't contain a valid alias configuration
Looked for and couldn't find the file at the following paths:
Desired behavior
I’m expecting it to report the error in particular test with line number, if possible.
Test code to reproduce
You can reproduce this error with following code anywhere in the test
const { fakeServer } = require("cypress/types/sinon")
describe('example to-do app', () => {
it('throws Webpack Compilation Error', () => {
fs.readFile("fileDoesn'tExist.js"); //sorry-cypress not working
});
});
or
const { fakeServer } = require("cypress/types/sinon")
describe('example to-do app', () => {
it('throws Webpack Compilation Error', () => {
cy.then( () => {
throw new Error("on my wish");
})
});
});
Cypress Version
8.0.0, 8.3.1
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
webpack: Module not found: Error: Can't resolve (with relative ...
Your file structure says that folder name is Container with a capital C. But you are trying to import it by container with...
Read more >Module | webpack - JS.ORG
Ignored files should not have calls to import , require , define or any other importing mechanism. This can boost build performance when...
Read more >Code Splitting - webpack
Dynamic Imports: Split code via inline function calls within modules. Entry Points. This is by far the easiest and most intuitive way to...
Read more >TypeScript - webpack
First install the TypeScript compiler and loader by running: ... Here we declare a new module for SVGs by specifying any import that...
Read more >Module Federation - webpack
Uncaught TypeError: fn is not a function ... You are likely missing the remote container, make sure it's added. If you have the...
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 FreeTop 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
Top GitHub Comments
I found that this issue has been resolved in Cypress v8.4.1
Sure I’ll create a repo and share the link