This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
SyntaxError: Unexpected token 'export'
> 1 | import PNotify from 'pnotify/dist/es/PNotify';
| ^
2 | import PNotifyButtons from 'pnotify/dist/es/PNotifyButtons';
3 |
4 | const createNotificationType = 'CREATE_NOTIFICATION';
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
at Object.<anonymous> (src/store/Notifications.js:1:1)
babel.config.js
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current"
}
}
],
,
["@babel/preset-typescript"],
["@babel/preset-react"],
],
plugins: ["transform-es2015-modules-commonjs","pnotify"]
一直这个问题,各位大佬,能给我解释下什么问题吗?十分感谢
我也一样的报错