I am having trouble configuring Jest to allow import statements in test files.
simple.test.js
import { foo } from "utils";
test('try-catch works', async () => {
try {
throw "error";
} catch (e) {
expect(e).toMatch("error");
}
});
.babelrc
{
"presets": [
"@babel/preset-env"
]
}
Versions:
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.16.11",
"babel-jest": "^27.5.1",
"jest": "^27.5.1"
},
Error:
SyntaxError: Cannot use import statement outside a module
How should I configure Jest here?