[Bug]: Use .mts file extension with ts-jest
See original GitHub issueVersion
28.0.7
Steps to reproduce
Steps:
- clone my repo at https://github.com/shiftcode/ts-jest-issue
npm install
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 ists-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:
- Created a year ago
- Reactions:1
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 themoduleNameMapper
hinted at earlier in the thread but I’m not sure I fully understood that.Thanks @ahnpnl. Any rough estimation, when this is released?