-
Notifications
You must be signed in to change notification settings - Fork 460
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
jest@28 support #3453
Comments
The fix should be trivial fwiw, just make sure ts-jest/src/legacy/ts-jest-transformer.ts Line 236 in 6e44f82
|
We had a release at |
Ah, nice! (Should've pinged you when making the change @ahnpnl, sorry about that) |
It ts-jest latest version doesn't support jest 28 yet? |
Using the
|
true, but like the message says, if you include this in your jest.config.js that warning goes away
|
Thanks! Adding |
We plan a refactoring to switch to |
Is there already a built-in way to use If not then would it be worth making it opt-in for v28, and then making it the default (with legacy option also available) in v29 once stability/compatibility/etc has been ensured? |
Nope we don't have it built in for v27 yet. Have it opt-in for v28 seems to be easier in term of refactoring. |
I haven't had any luck running my tests at all, even when updating to the latest versions of jest and ts-jest@next. I'll peruse for an issue that's currently open for what I'm looking at, but so far, the only ones I can see are closed and do not have suggestions that have fixed them. The warning that was mentioned to add the transform with For reference, the versions I'm using are |
What exactly not working? Do you have a reproduce scenario? |
I also would note that I was seeing the same behavior when I was on Node 16.14.0, right before installing the latest version of Node. My console shows the following when I run it:
The jest configuration looks like: module.exports = {
moduleDirectories: [
"node_modules"
],
moduleFileExtensions: [
"js",
"mjs",
"ts"
],
extensionsToTreatAsEsm: [
".ts"
],
preset: "ts-jest/presets/default-esm",
testMatch: [
"**/__tests__/**/*.[jt]s?(x)"
],
transform: {
"^.+\\.tsx?$": "ts-jest/legacy"
},
globals: {
"ts-jest": {
tsconfig: "tsconfig.test.json",
useESM: true
}
}
}; |
That |
When poking around, it would seem that, though the TypeScript + Node ESM requires the |
I was considering that perhaps a custom resolver that simply wraps the vanilla resolver code could work, possibly checking if there isn't a I'm still not sure about the packages, however. That seems a bit wrong to me, as the documentation and type definitions both support that it's being done correctly, so long as the interop is working how it's supposed to. I'm wondering if there's something wrong with resolving the node module inside of jest itself or if something else is wrong. |
|
This error was happening before updating to Jest 28 and I don't know that the jest resolver is supposed to resolve I can't adjust the |
While esbuild is great (we are using it selectively), please note that it is not 100% compatible with many experimental (yet widely used) TypeScript features. For example, we are using emitDecoratorMetadata which esbuild author has stated is impossible to support. That feature is needed by several libraries (I think Angular and next.js, but I'm not 100% sure about that - we are using graphql-modules that needs it). AFAIK one of SWC authors stated to reimplement tsc in golang, but that work has only started. I believe we will be stuck with "legacy" mode for quite a while... |
Thanks for the information. Indeed I ran into a few issues with |
I smashed together a resolver wrapping the default resolver for jest, just changing the extensions to |
Is there a way to hide the warning:
I have already added |
The warning has been reverted in #3466 :) |
I think this is expected because this is Jest error. |
Yes, this is issue with |
So im doing the steps mentioned above with the ts-jest/legacy, using the next version and im setting NODE_OPTIONS=--experimental-vm-modules as im using esm, and i keep getting this error
any clue on how to fix this |
Not sure what it is, maybe you can try to reproduce with our example React app https://github.com/kulshekhar/ts-jest/tree/main/examples/react-app ? I think that error might be related to Jest resolver, or something which contains |
might be the testing lib as they are the only import in that file. |
Yeah just changed it to this instead.
and i got ReferenceError: exports is not defined |
I think something with |
This is a temporary measure until kulshekhar/ts-jest#3453 is fixed. Signed-off-by: David Mehren <git@herrmehren.de>
@ahnpnl - I've run into the
|
@scott-lc I've just cleared the cache and im still getting
is there anything else that you think might help? edit: strange if i switch the imports around i get this
|
@The-Code-Monkey would be nice if you can provide a reproduce repo here. We have an example app for React https://github.com/kulshekhar/ts-jest/tree/main/examples/react-app you can use this to put your reproduce scenario. |
I've actually just fixed it, it seems it was because I wasn't using, the globals object in my jest config. This hidden thing wasn't really documented anywhere in the readme might be good to add it |
Probably you didn't check the online doc https://kulshekhar.github.io/ts-jest/docs/guides/esm-support |
ts-jest does not yet support Jest@28. Follow the issue here: <kulshekhar/ts-jest#3453>
* Downgrade to Jest@27 ts-jest does not yet support Jest@28. Follow the issue here: <kulshekhar/ts-jest#3453> * Move cypress and netlify to optionalDep Begin general dep cleanup * Enforce unix-style endings * Add netlify-api-test GitHub action * Move aws-lambda to devDeps * Create test .env in CI
* Fix gauth error * Allow headers on rejection / error response * Add Access-Control-Allow-Credential headers * Return "OK" for OPTION methods * Correct OPTION method to OPTIONS plural * Add Access-Control-Allow-Headers ... to Access-Control-Allow-Headers * Allow cross-origin script access * Add frontend script + webpack build * Allow gauth to retrieve token * Update apiClient * Create discussion area if not found * Add Referrer-Policy to CORS allowed headers * Create discussion div if not found * Add CSS distributable Note this is not acceptable for production, since it adds styles directly to elements like 'body' * Include credentials for all requests * Improve message for modify admin error * Remove unused * Set SameSite to None * Limit recursion on error * Immediate login after signup * Allow Authorization header * Show user id in logged-in status * Set SameSite to None at auth delete (log out) * Add #user-display to DOM * Remove js based Referrer Policy header * Add nice-to-haves * Add source-map to x-origin script * Improve user endpoint error messages * Troubleshoot missing auth * Do not ignore jwt expiration * Equalize expiration date between cookie and token * Login request on expire From a UXD perspective, this is less than optimal, but let's punt handling this until the frontend update * Expire auth in 1 year * Hide log-in form * Handle expired token server-side Just return 'null' * Hide user auth * Update jwt expiration * Add login before comment submit * Fix jwt expiration error * Hide user display * Hide user-display * Update x-origin css * Add JSDocs * Set API URL via setSimpleCommentApiUrl() * Guests can update / change name * Clear type errors * Add helpful error message * Use proper endpoint for userPUT * Update badge * Update badge * Update done and todo * Remove extraneous html elements * Add Twitter card logo * Cleanup * API URL as .env variable * Remove StyleCI Default open-source license is for PHP only, unnecessary as this project does not use PHP * Update README.md * Update README.md * Remove extraneous obsolete .env variables * Update basic description * Rewrite demo intro * Write more positive intro * Clean layout with detail-summary accordion * Remove help cursor from anchors with [title] Not having the cursor:pointer is potentially confusing * Add 'alternative solution' pros-cons lists * Add build dependencies to "dependencies" * Install Cypress * Close issue #35 `Frontend testing with Cypress` Merging this branch will include Cypress and essential tests for Simple Comment frontend * Initial documentaion and tests * Update '#simple-comment-area' to '...-display' * Update frontend element nomenclature Element ids with '-input' or '-textarea' changed to generic '-field' "#simple-comment-area" changed to more specific "...-display" * Change .env SIMPLE_COMMENT_MODE to IS_CROSS_SITE This change clarifies its purpose * Minimal functionality frontend test * Complete CYPRESS doc * Test client input validation * Create LICENSE Punt the question to readers * Add more alternatives! * AGPL 3 * Update abstract Service tests Upgraded TypeScript no longer compiles abstract classes, so Service must be implemented as TestService * Upgrade dependencies * Remove bson It's a dependency's dependency * Upgrade TypeScript to 4.4.3 * Fix module reference * Update landing page styling * Format Service.ts * Update dependencies (#44) * Fix type error * Upgrade dependencies * Update dependencies (#46) * Change `IS_CROSS_SITE` instructions to boolean fixes #47 * Update example.env List env variables in order they appear in Netlfify (alphabetical) * Remove David badge * Update secrets test * Set Node version * Upgrade mongodb client to latest minor version * Address Dependabot alerts * Implement SECURITY policy * Create codeql.yml * Upgrade/dependencies (#50) * Upgrade dependencies to latest where possible * `mongodb@3.7.3` => `mongodb@^4.5.0` * `typescript@4.3.5` => `typescript@^4.6.3` * Update failing Cypress tests * Lighthouse update * Remove netlify-lambda build tool * mitigate glob-parent vulnerability. * Update SECURITY.md * Add action to test netlify functions (#51) * Downgrade to Jest@27 ts-jest does not yet support Jest@28. Follow the issue here: <kulshekhar/ts-jest#3453> * Move cypress and netlify to optionalDep Begin general dep cleanup * Enforce unix-style endings * Add netlify-api-test GitHub action * Move aws-lambda to devDeps * Create test .env in CI * Remove swagger-generated API docs (#52) * Update/cleanup (#53) * Fix async security alert * Change interfaces to types * Update slug * Move mock data to its own file * Reset mocks after each test * Update/cleanup (#54) * Update mock data function names * Add eslint * Format * Add eslint-watch * Implement linter advice * Configure linter
Still doesn't seem to work out of the box with jest v29 for me.. |
This was an issue about v28, not v29... |
@glasser well looks like ts-jest is still having the same issue with v29 as with v28 |
@tnrich do you have a reproducer? |
π Feature Proposal
Jest 28 has landed.
Doesn't work with current
ts-jest
as-is, gives this error:Created this issue to track when jest28 support will land here.
Thanks.
Motivation
Β
Example
No response
The text was updated successfully, but these errors were encountered: