Jest transformIgnorePatterns not working Jest transformIgnorePatterns not working reactjs reactjs

Jest transformIgnorePatterns not working


The transformIgnorePatterns didn't work for me until I changed my .babelrc to babel.config.js, like this:

module.exports = {    "presets": [        "@babel/preset-env"    ]};

as seen on this comment: https://github.com/facebook/jest/issues/6229#issuecomment-403539460


As a workaround for now I have changed my config to use the moduleNameMapper option to load a mock class for that library instead. I would have preferred to use transformIgnorePatterns instead so would still appreciate any ideas.

New config:

module.exports = {    moduleNameMapper: {        '\\.(css|scss)$': 'identity-obj-proxy',        '\\.svg$': '<rootDir>/test/mocks/svg-mock.js',        'mathletics-portal-communication-service': '<rootDir>/test/mocks/mathletics-portal-communication-service-mock.js'    },    setupFiles: ['./test/test-setup.js']};


Adding trailing slash fix this for me:

{    // ...    transformIgnorePatterns: [        '<rootDir>/node_modules/(?!mathletics-portal-communication-service/)'    ]};