我已经花了很长时间查看其他与此相关的问题以及在Github上查看其他项目,但是没有一个答案对我起作用。
我正在将第三方库加载到我的项目中,在运行Jest测试时出现错误
export default portalCommunication;
^^^^^^
SyntaxError: Unexpected token export
> 1 | import portalCommunication from 'mathletics-portal-communication-service';
我尝试了多种方式更新我的Jest配置来使它转译这个库,但是我总是得到相同的错误。
这是我的当前jest.config.js文件:
module.exports = {
moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy',
'\\.svg$': '<rootDir>/test/mocks/svg-mock.js'
},
setupFiles: ['./test/test-setup.js'],
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!mathletics-portal-communication-service)'
]
};
我也尝试添加transform属性,以便对mathletics-portal-communication-service目录运行babel-jest。
请帮忙!