Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I just updated to jest 24 and it seems like transformIgnorePatterns does not work.

this is the error I receive:

/Users/lemoustachiste/work/frontend/node_modules/my-untranspiled-package/build/bundle.js:7948
    export default Package$1;
    ^^^^^^
    SyntaxError: Unexpected token export

jest config:

module.exports = {
  'modulePaths': [
    '<rootDir>/src/',
    '<rootDir>/node_modules'
  'transformIgnorePatterns': [
    'node_modules/(?!(my-untranspiled-package)/)'
  'transform': {
    '^.+\\.(ts|tsx)$': 'ts-jest',
    '^.+\\.(js|jsx)$': 'babel-jest',
    '^.+\\.(scss|ico)$': '<rootDir>/tests/importStub.js'
  'setupFiles': [
    '<rootDir>/tests/jest-aurelia.config.ts'
  'setupFilesAfterEnv': ['<rootDir>/tests/jest-framework.config.ts'],
  'testRegex': '\\.(test|spec)\\.(ts|js)x?$',
  'globals': {
    'ts-jest': {
      'diagnostics': false

The project is still configured for babel 6. It is working fine with Jest 23.

So I started by updating to babel 7 but still encountered the issue. I then found this comment: https://github.com/facebook/jest/issues/7578#issuecomment-451671656

which pointed to this part of the docs: https://jestjs.io/docs/en/getting-started#using-babel

And sure enough, extracting the babel config to its own file out of the package.json fixed the issue.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.