相关疑难解决方法(0)

Jest transformIgnorePatterns无效

我花了很长时间查看有关此问题的其他问题并查看Github上的其他项目,但似乎没有任何答案对我有用.

我正在我的项目中加载第三方库,当运行Jest测试时,我收到错误

export default portalCommunication;
^^^^^^

SyntaxError: Unexpected token export

> 1 | import portalCommunication from 'mathletics-portal-communication-service';
Run Code Online (Sandbox Code Playgroud)

我已尝试以多种方式更新我的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)'
    ]
};
Run Code Online (Sandbox Code Playgroud)

我还尝试添加transform属性来对这个mathletics-portal-communication-service目录运行babel-jest.

请帮忙!

javascript reactjs jest babel-jest

12
推荐指数
4
解决办法
3435
查看次数

标签 统计

babel-jest ×1

javascript ×1

jest ×1

reactjs ×1