Skip to content

Confusing behavior when ts-jest fails to parse TypeScript files #2513

@colelawrence

Description

@colelawrence

💥 Regression Report

This is affecting us ever since updating to latest ts-jest (v26.5.4), where I saw this warning added for clarity:

ts-jest[ts-compiler] (WARN) Unable to process '/Users/cole/story/storytime-pr/packages/driver-sdk/src/internal/runtime/ServiceManager/ServiceManager.ts', falling back to original file content. Please make sure that outDirin your tsconfig is neither''or'.'. You can also configure Jest config option transformIgnorePatterns to ignore /Users/cole/story/storytime-pr/packages/driver-sdk/src/internal/runtime/ServiceManager/ServiceManager.ts from transformation

Unfortunately, instead of erroring there, ts-jest continues to pass the file's contents over to jest, which fails with many errors relating to not being able to parse TypeScript files (see screenshot).

NOTE: In this screenshot I had diagnostics: false

image

Last working version

I think it's the behavior change made here: c2b2164

Output with rollback to ts-jest@=26.5.2

NOTE: In this screenshot I had diagnostics: true

image

To Reproduce

Steps to reproduce the behavior:

  1. Take any ts-jest configured project and add invalid syntax like export a = 1
  2. Run tests and observe the Jest error

Expected behavior

I expect that the file fails to compile and there is a clear compilation error in my ts-jest output.

Link to repo (highly encouraged)

Debug log:

# content of ts-jest.log :

envinfo

Not applicable

System:
    OS: macOS Catalina

Npm packages:
    jest: 26.6.3
    ts-jest: 26.5.4
    typescript: 4.2.3

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions