How test with Jest?
See original GitHub issueI’m trying to setup Jest tests configuration for my project. I use imports-loader to load some old jQuery libs
import 'imports-loader!jquery-mousewheel'
When running tests with jest I get following error:
Cannot find module 'imports-loader!jquery-mousewheel' from 'SomeModule.js'
As a workaround, I mock all imports-loader in Jest config
"moduleNameMapper": {
"imports-loader?.*": "<rootDir>/internals/mocks/importsLoader.js"
},
// importsLoader.js
module.exports = 'IMPORTS_LOADER_MOCK';
How to configure it to actually import correct module?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Jest · Delightful JavaScript Testing
Jest is a JavaScript testing framework designed to ensure correctness of any JavaScript codebase. It allows you to write tests with an approachable, ......
Read more >Jest Tutorial for Beginners: Getting Started With JavaScript ...
Jest is a JavaScript test runner, that is, a JavaScript library for creating, running, and structuring tests. Jest ships as an NPM package,...
Read more >Jest Testing Tutorial: 5 Easy Steps - Testim Blog
1. Install Jest Globally · 2. Create a Sample Project · 3. Add Jest to the Project · 4. Write Your First Test...
Read more >Jest Tutorial - JavaScript Unit Testing Using Jest Framework
Jest is a Javascript Testing framework built by Facebook. It is primarily designed for React (which is also built by Facebook) based apps...
Read more >Testing with Jest
Jest is a Javascript Testing Framework by Facebook. It is used most commonly for unit testing. Unit testing is when you provide input...
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
Thanks @darkowic I needed just a solution to mock all the
require('imports!...')
blocks, yourmoduleNameMapper
solution worked for me 👍Here a lot of examples - https://jestjs.io/docs/en/webpack, if somebody still have problems, please open an issue in jest