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

@ngneat/spectator does not work with Angular CLI's Jest builder #677

Open
Tommy228 opened this issue Oct 23, 2024 · 0 comments
Open

@ngneat/spectator does not work with Angular CLI's Jest builder #677

Tommy228 opened this issue Oct 23, 2024 · 0 comments

Comments

@Tommy228
Copy link

Tommy228 commented Oct 23, 2024

Is this a regression?

No

Description

Hi,

The Angular team has already announced some time ago their transition to Jest here. We can already play with an experimental version.

I have noticed that it does not work with Spectator which may become an issue.

Please provide a link to a minimal reproduction of the bug

https://github.com/Tommy228/spectator-angular-builders-jest

Please provide the exception or error you saw

dist/test-out/ca3e369e-b853-4b8a-a768-4d0075c3d656/app.component.spec.mjs
  ● Test suite failed to run

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

      at node_modules/@jest/globals/build/index.js:11:7

Please provide the environment you discovered this bug in

No response

Anything else?

I'm not sure why this happens and if this is an issue with Spectator or Angular's builder. What the builder does is simply building the whole app then running Jest ESM by invoking a node process (code here), so why are we outside of the "Jest test environment"?

An easy fix might be using import.meta.jest instead of importing jest as mentioned in the Jest ESM documentation.

Do you want to create a pull request?

Yes

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

1 participant