-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -20,7 +24,7 @@ test('works with single typescript config that imports something', () => { | |||
'__tests__/mytest.alpha.js': "test('alpha', () => expect(1).toBe(1));", | |||
'__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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonderful, thank you!
Hmm, snapshot test seems to be failing on 23.7 😅 |
Summary
see https://nodejs.org/api/process.html#processfeaturestypescript
This value is set if node is run with
--experimental-transform-types
or--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-package
patch via apollographql/apollo-client@795a432
(#12305) in apollographql/apollo-client#12305.The tests still run fine despite
ts-node
not being installed and the config file being a.ts
file.proof for ts-node not being present: