-
-
Notifications
You must be signed in to change notification settings - Fork 10
Support Jest 29 #13
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
Support Jest 29 #13
Conversation
@rschristian @marvinhagemeister Could you probably have a look at these changes? Thanks. |
I'd say I'm a bit apprehensive about this. Jest 28 brought with it the ability resolve package exports., Notably, it will consume Edit: To clarify, not apprehensive about your work here, but in moving to Jest 28 at this time. |
Is this preset likely to support Jest 29 in the near future? I'm currently having to wire things up manually, but I'd prefer to use an official preset. |
Sorry for the long delay here.
I'm not quite sure what you mean; neither are pure ES modules. Both ship CJS and ESM. Re: Jest 28 + jsdom, I'm told the following can help (though haven't tested myself) {
"testEnvironmentOptions": {
"customExportConditions": [
"node",
"node-addons"
]
}
} |
src/preset.js
Outdated
@@ -44,4 +44,12 @@ module.exports = { | |||
|
|||
// Default is "node", but we need browser APIs | |||
testEnvironment: 'jsdom', | |||
|
|||
// Load node exports (CommonJS) |
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.
This isn't to load the CJS output, no. As mentioned, Jest (w/ jsdom) will consume Preact's browser build while (incorrectly) applying Node extension semantics -- i.e., .js
in a non-"type": "module"
project will be treated as CJS.
What we need to do is ensure Jest doesn't consume the browser build, despite this being a mistake on their end. Users can still get ESM, just through the "import"
condition instead.
This seems to work, thanks a lot! I could rewind most of my changes, what's left is this snippet and some eslint config changes necessary because of the dependency update. |
Oh good! But never mind, don't bother reverting. Need to bump those things at some point. |
Co-authored-by: Ryan Christian <[email protected]>
I think we also need to move
|
Thanks! |
Thank you too! 🥳 |
I've been running our tests with 58b961c and suddenly unrelated tests fail. To be specific, we have Preact and Svelte front-end component tests in one project. The update of jest-preset-preact makes some Svelte tests fail because the
This also seems to affect the loading of the Svelte library. Since the "node" export is loaded instead of the "browser" export, the server-side renderer gets active instead of the client-side renderer. But in the Jest/jsdom environment, my tests expect the client-side renderer. Minimal demo is here: Do you have any ideas how to solve this? Thanks! |
Makes sense, and maybe this change wasn't optimal to land. While Preact doesn't have any differences in its browser and ESM builds, others could. However, so long as Jest w/ jsdom continues to apply Node semantics to non-Node exports, there's gonna be an issue. I don't use Jest, but any chance there's a way to set export conditions for a particular module? So we can ensure Preact's Node ESM build gets loaded instead of the browser? Edit: Took a look around, ended up opening jestjs/jest#13820 |
This updates all dependencies, drops support for Jest 26 and adds support for Jest 29.
Jest 26 support is dropped because
jest-watch-typeahead
has a peer dependency on Jest 27+.I'm using a shared Babel config and need to transformpreact
andpreact-render-to-string
, which are pure ESM modules.Let me know if this makes sense.