Skip to content

[V4] custom jest transforms (e.g. ts-jest) no longer working #9667

@jrr

Description

@jrr

Tried out 4.0.0-next.98 today (coming from 3.4.3) in a medium-sized typescript monorepo. Our app builds and runs just fine.

Unfortunately some of our Jest tests broke. It looks like ts-jest is no longer getting used. Previously (with CRA3) we were able to specify a transform in the jest section of package.json like this:

    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/ts-jest"
    },

This allowed us to use TypeScript features not supported by Babel (like emitDecoratorMetadata for TypeORM).

Looking at the v3.4.1...master diff, I'm not sure what broke it. Perhaps something about Jest 26?

I will try to produce a repro repo when I can.

Repro steps in short:

  • npx create-react-app --template typescript my-react-app
  • add a const enum to the test (not supported by babel)
  • yarn test (see it fail)
  • install ts-jest and add the transform line above
  • yarn test (see it pass)
  • update to react-scripts 4.0.0-next.98, see yarn test break again.

Example repo here: https://github.com/jrr/cra-4-ts-jest-issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions