I use webpack to develop a React component. Here is a simple version of it:
\'use strict\';
require(\'./MyComponent.less\');
var React = require(\'react\')
It has been 5 years since this question asked, yet its still very confusing for me, I can't believe that its so hard to make jest and webpack works, until I tried this:
Add babel-jest and babel preset:
yarn add --dev babel-jest @babel/preset-env
Add babel config:
// babel.config.js
module.exports = {
presets: ["@babel/preset-env"]
};
This may or may not work for you, since the question title only refers to jest and webpack, people may stumble upon this article just like me that's clueless how to make jest works with webpack, and I hope at least my answer helped them if this doesn't help you.