-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Can't import things from @apollo/client with Jest ESM and ts-jest #9156
Comments
At least this part
should be fixed now since there is now a correct |
Hi is this issue resolved? We're experiencing this as well. Thanks |
Doing some housekeeping and I'll be closing this as a duplicate since it's related to ESM support, thanks! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Intended outcome:
Import things from apollo client in jest unit tests (ts-jest and esm)
Actual outcome:
Each of the imports gives an error like
SyntaxError: The requested module '@apollo/client' does not provide an export named 'ApolloProvider'
. Looking at the@apollo/client
's package.json, the"main"
key is set to"./main.cjs"
, which is re-exporting things in cjs style:For some reason I guess this cjs is not recognized with the recommended jest config. To get around it, can directly import the specific exports directly from esm files in the
@apollo/client
package like this:Then there's a new error for a dependency:
Adding
transformIgnorePatterns
to jest config doesn't seem to help:Full jest config:
and tsconfig:
How to reproduce the issue:
Minimal repro: https://github.com/themaskedavenger/jest-esm-apollo-client
Versions
System:
OS: macOS 11.6
Binaries:
Node: 14.17.6 - /usr/local/bin/node
Yarn: 1.22.0 - /usr/local/bin/yarn
npm: 6.14.15 - /usr/local/bin/npm
Browsers:
Chrome: 96.0.4664.55
Edge: 80.0.361.54
Firefox: 89.0.2
Safari: 14.1.2
npmPackages:
@apollo/client: ^3.5.5 => 3.5.5
The text was updated successfully, but these errors were encountered: