question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Use .mts file extension with ts-jest

See original GitHub issue

Version

28.0.7

Steps to reproduce

Steps:

  1. clone my repo at https://github.com/shiftcode/ts-jest-issue
  2. npm install
  3. npm run test

Expected behavior

Test should run successfully without any complains.

Actual behavior

I am seeing the following WARN message from ts-jest:

ts-jest[ts-jest-transformer] (WARN) Got a unknown file type to compile (file: /Users/michaelwittwer/dev/shiftcode/esm-ts-jest/src/util.spec.mts). To fix this, in your Jest config change the transform key which value is ts-jest so that it does not match this kind of files anymore.

Which prevents the tsc compiler to compile the source to mjs.

Debug log

to long to be pasted here, you can execute npm run test:debug to see the log after checking out the repo

Additional context

No response

Environment

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Max
Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
npmPackages:
    jest: ^28.1.3 => 28.1.3

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
anthonyhastingscommented, Aug 1, 2022

I also have a use case similar to @michaelwittwer where I’d like to have my test file extensions as .mts and also import .mjs files within them. I’m curious to know when this fix is going to be released, and if it fixes the aforementioned test repo. I tried making the fix changes directly in the local node modules folder but it didn’t help matters. That might be due to the moduleNameMapper hinted at earlier in the thread but I’m not sure I fully understood that.

1reaction
michaelwittwercommented, Jul 26, 2022

Thanks @ahnpnl. Any rough estimation, when this is released?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Diagnostics option | ts-jest - GitHub Pages
The diagnostics option configures error reporting. It can both be enabled/disabled entirely or limited to a specific type of errors and/or files ...
Read more >
Unknown file extension ".ts" error appears when trying to run a ...
When you want to use ts-node you should try running the file with ts-node scripts.ts instead of node scripts.ts .
Read more >
An import path cannot end with a '.ts' extension in TS
The error "An import path cannot end with a '.ts' extension" occurs when we include the extension when importing TypeScript files. To solve...
Read more >
Configuring Jest
The file will be discovered automatically, if it is named jest.config.js|ts|mjs|cjs|json . You can use --config flag to pass an explicit ...
Read more >
Announcing TypeScript 4.7 - Microsoft Developer Blogs
When a .ts file is compiled as an ES module, ECMAScript import ... In turn, TypeScript supports two new source file extensions: .mts...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found