Answer the question
In order to leave comments, you need to log in
How to use Jest and webpack imports?
Z bundle files with webpack and use its imports which it then bundles
export function sum(a, b) {
return a + b;
}
import { sum } from "./index";
test("Sum of numbers", () => {
expect(sum(1, 3)).toBe(4);
expect(sum(6, 7)).toBe(15);
expect(sum(12, 12)).toBe(24);
expect(sum(24, 24)).toBe(48);
})
SyntaxError: Cannot use import statement outside a module
{
test: /\.js(x)?$/,
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
plugins: [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-private-methods",
],
},
exclude: /node_modules/,
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question