kulshekhar / ts-jest

A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.

Home Page:https://kulshekhar.github.io/ts-jest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Tests failed due to error "registerer.enabled is not a function"

belyan opened this issue · comments

Version

27.1.4

Steps to reproduce

  1. Create new angular app with NX 14.0.5
  2. Run tests with command nx run my-app:test

Expected behavior

Jest tests are passed without any errors.

Actual behavior

Tests failed with error

Jest: Failed to parse the TypeScript config file /var/teamcity/agent/work/511c4cac333fab38/libs/***/jest.config.ts
[18:05:11]  TypeError: registerer.enabled is not a function 

Debug log

Log file is not created

Additional context

https://stackoverflow.com/questions/68960179/jest-config-ts-registerer-enabled-is-not-a-function-error-when-running-jest-f

Environment

System:
    OS: macOS Sierra 10.12.6
    CPU: (8) x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    npm: 8.5.0 - /usr/local/bin/npm
  npmPackages:
    jest: 27.5.1 => 27.5.1
commented

This error isn’t related to ts-jest, the error indicates about something with ts-node. You should check with Jest community or search a bit more on google or debug to see what happened.

In general this error happens when you use Jest config in TypeScript which Jest uses ts-node to process that file.

ts-jest is code transformation which means it only executes on test files or files which are imported by test files, see more at https://jestjs.io/docs/code-transformation