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.

Jest = Can not find module

See original GitHub issue

Hello,

I have a problem with Jest, when I run a test I have this error:

Cannot find module ‘sass-extract-loader?{“plugins”: [“sass-extract-js”]}!./theme/variables.scss’ from ‘index.tsx’

My code :

const theme = require('sass-extract-loader?{"plugins": ["sass-extract-js"]}!./theme/variables.scss')

ReactDOM.render(
  <ThemeProvider theme={theme}>
    ...
  </ThemeProvider>
)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
adamgrubercommented, Jun 3, 2019

🤔 This may be an issue with sass-extract-loader rather than this plugin.

0reactions
adamgrubercommented, Aug 13, 2019

Unfortunately this is a limitation with jest-resolver not understanding the webpack import syntax.

You could try mocking the loader similar to how it’s done in this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Jest gives `Cannot find module` when importing ...
I think you're looking for: roots or modulePaths and moduleDirectories. You can add both relative and absolute paths.
Read more >
Upgrade to v28 complains "Cannot find module '@jest/ ...
This is was fixed it for me. I removed resolver: 'jest-node-exports-resolver' and changed it from: module.
Read more >
Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
Read more >
cannot find module 'jest-util'
If you are seeing the error "cannot find module 'jest-util'" when running a test in Jest [1][2], it is likely that you are...
Read more >
jest: configuring jest to resolve modules - code-comments
jest : configuring jest to resolve modules ; const path = require( ; import app from "./app.js" import ; find module 'usefulModule' ·...
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