feat(config): if process.features.typescript is set, load jest.config.ts without external loader#15480
Conversation
…t external loader see https://nodejs.org/api/process.html#processfeaturestypescript This value is set if node is run with `--experimental-transform-types` or `--experimental-strip-types` so no external package is required for transpilation in those cases
✅ Deploy Preview for jestjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Looking at the tests running Node23+ this seems to run really well 😆 Should I just update the snapshots there or should some of those tests be skipped in node 23? |
|
Exciting, thank you for the PR! We should suppress the warning to avoid it cluttering the output in tests ( jest/e2e/__tests__/nativeEsm.test.ts Line 67 in 7ea9a40 As for the syntax errors, it would be nice to update the error message for the "native" TS stripping. Might need 2 separate tests and use the |
| const jestTypesExists = fs.existsSync(jestTypesPath); | ||
|
|
||
| (jestTypesExists ? test : test.skip).each([true, false])( | ||
| 'check the config disabled (skip type check: %p)', |
There was a problem hiding this comment.
Skipping this test in new node versions since the node feature only transpiles and doesn't type check.
| (jestTypesExists ? test : test.skip).each([true, false])( | ||
| 'check the config disabled (skip type check: %p)', | ||
| skipTypeCheck => { | ||
| test('invalid JS in jest.config.ts', () => { |
There was a problem hiding this comment.
The diff is a bit weird here - this test is duplicated into a pre-23.6 and post-23.6 version now.
| skipPkgJsonCheck: true, | ||
| }, | ||
| ); | ||
| onNodeVersions('<=23.6', () => { |
There was a problem hiding this comment.
Node resolution modes cannot be configured via tsconfig.json in modern node TS - it just uses modern node resolution by default.
This test fails anyways, because it requires transpilation to happen - the package.json contains type: "commonjs" and the jest.config.ts is written in ESM style.
That fails native node. It would work with type: "module", but we wouldn't really test what this test is about at this point - so I'm skipping it.
| '__tests__/mytest.common.js': "test('common', () => expect(1).toBe(1));", | ||
| 'alpha.config.ts': ` | ||
| import commonRegex from './common'; | ||
| import commonRegex from './common${importFileExtension}'; |
There was a problem hiding this comment.
transpiled resolution is fine with './common', type-stripped node execution wants './common.ts'.
|
All tests green now if you want to take another look @SimenB :) |
|
Hmm, snapshot test seems to be failing on 23.7 😅 |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
see https://nodejs.org/api/process.html#processfeaturestypescript
This value is set if node is run with
--experimental-transform-typesor--experimental-strip-types(or you run an unflagged node version of >= 23.6) so no external package is required for transpilation in those casesTest plan
I'm introducing this change with a
patch-packagepatch via apollographql/apollo-client@795a432(#12305) in apollographql/apollo-client#12305.The tests still run fine despite
ts-nodenot being installed and the config file being a.tsfile.proof for ts-node not being present: