Skip to content
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

Do not import @jest/globals outside of the Jest test environment #45

Open
EvHaus opened this issue Jul 21, 2021 · 1 comment
Open

Do not import @jest/globals outside of the Jest test environment #45

EvHaus opened this issue Jul 21, 2021 · 1 comment

Comments

@EvHaus
Copy link

EvHaus commented Jul 21, 2021

Hi there. Another adventurer trying to migrate from babel-jest to esbuild-jest. I'm noticing that many tests which use jest.mock are failing with:

Do not import `@jest/globals` outside of the Jest test environment

Sometimes moving the jest.mock() call inside the describe() block helps resolve the issue, but other times not. Seems like babel-jest was more flexible about where mocking can occur. Any tips on how we can update our tests to avoid these issues?

@dave-irvine
Copy link

I believe in this case you need to tell esbuild to external the @jest/globals module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants