Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
colelawrence opened this issue Apr 13, 2021 · 2 comments
Closed

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

colelawrence opened this issue Apr 13, 2021 · 2 comments

Comments

@colelawrence
Copy link

@colelawrence colelawrence commented Apr 13, 2021

馃挜 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
@colelawrence
Copy link
Author

@colelawrence colelawrence commented Apr 13, 2021

In reference to this change fixing: #2407 (comment)

I would suggest either only passing the contents down with a warning if the extension is not tsx?$, or adding configurability of this via a setting.

Loading

@ahnpnl
Copy link
Collaborator

@ahnpnl ahnpnl commented Apr 13, 2021

I agree, we should only return the content if file name doesn't end with ts or tsx extension with a warning otherwise throwing error.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants