-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 encountered an unexpected token export with the adapter #179
Comments
This error suggests that Jest is trying to parse an ES module as if it were a CommonJS module. It is loading the CommonJS build of enzyme-adapter-preact-pure (see What I would normally expect to happen is that a bundler / environment either uses the ES module build of both, if it supports that, or the CommonJS build of both. Can you provide the details needed to recreate your project setup? |
Hmm... I tried a couple things, I initially used Any reason why jest would load the es module version of preact instead of cjs? (Using Node 16, my swc/jest config has |
Can you import functions from the |
I believe there's a misunderstanding. I'm simply trying to do the initial setup to add the preact adapter for enzyme. Tests are importing After a bit more try and error, starting from scratch again, and removing all complexity (all tests and typescript) , it seems the error arises as soon as I set |
After rollback to jest 27, it seems the error is gone. So might be a problem with Jest 28, or somewhere in between Jest and this adapter? |
Same here, met exactly the same issue after upgrading to jest 28, and have to downgrade back to 27 to make the original tests work... |
If someone could create a gist with the minimal set of files needed to reproduce the problem in a project, that would be helpful. I'm not currently using Jest together with Preact in any projects, so this would save some debugging time. |
Might be related to jestjs/jest#11924 Sounds like Jest is consuming the browser build of Preact while applying Node extension semantics to it. |
After a lot of fiddling, I was able to fix it based on ai/nanoid#363 (comment) Add the following to "^preact(/(.*)|$)": "preact$1" |
I'm trying to set up a new project, and simply adding these give me an error:
In the details of the error, it looks like it might be trying to parse the preact.module.js file?
Not sure exactly what's going on. Am I missing an obvious option?
The text was updated successfully, but these errors were encountered: