开玩笑 transformIgnorePatterns 不起作用

新手上路,请多包涵

我花了很长时间查看有关此的其他问题并查看 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。

请帮忙!

原文由 Heather Roberts 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 734
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题