question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack Compilation Error when module is not imported

See original GitHub issue

Current 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:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
amitguptagwlcommented, Sep 19, 2021

I found that this issue has been resolved in Cypress v8.4.1

0reactions
amitguptagwlcommented, Sep 17, 2021

Sure I’ll create a repo and share the link

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found