We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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/globals
No
Error when importing from "@ngneat/spectator/jest".
TLDR; I suspect this is due to using @angular-devkit/build-angular:jest rather than jest-preset-angular
@angular-devkit/build-angular:jest
jest-preset-angular
N/A
`Do not import `@jest/globals` outside of the Jest test environment`
Angular CLI: 17.0.8 Node: 20.11.0 Package Manager: npm 10.2.4 OS: win32 x64 Angular: 17.0.8 ... animations, common, compiler, compiler-cli, core, forms ... platform-browser, platform-browser-dynamic, router, upgrade Package Version --------------------------------------------------------- @angular-devkit/architect 0.1701.2 @angular-devkit/build-angular 17.1.2 @angular-devkit/core 17.1.2 @angular-devkit/schematics 17.0.8 (cli-only) @ngtools/webpack 17.1.2 @schematics/angular 17.0.8 (cli-only) rxjs 7.8.1 typescript 5.2.2 webpack 5.89.0 zone.js 0.14.2
Simple spec file:
import { Spectator, createComponentFactory } from "@ngneat/spectator/jest"; import { ContactsComponent } from "./contacts.component"; import { HttpClientTestingModule } from "@angular/common/http/testing"; import { ContactsService } from "@kno2/data-access/contacts"; import { AppModule } from "AppNgx/app/app.module"; import { SocketService } from "@kno2/shared"; describe("ContactsComponent", () => { let spectator: Spectator<ContactsComponent>; const createComponent = createComponentFactory({ component: ContactsComponent, imports: [HttpClientTestingModule], overrideModules: [[AppModule, { set: { providers: [] } }]], mocks: [ContactsService, SocketService], shallow: true }); beforeEach(() => (spectator = createComponent())); it("should create", () => { expect(spectator.component).toBeTruthy(); }); });
The text was updated successfully, but these errors were encountered:
Hello, is there any workaround for this issue? I also get error Do not import @jest/globals outside of the Jest test environment, when using:
Sorry, something went wrong.
@teokosmo
I've yet to try again. I ended up using Angular's basic testing modules + ng-mocks
I have created a bug on Angular CLI's side: angular/angular-cli#28722
No branches or pull requests
Is this a regression?
No
Description
Error when importing from "@ngneat/spectator/jest".
TLDR; I suspect this is due to using
@angular-devkit/build-angular:jest
rather thanjest-preset-angular
Please provide a link to a minimal reproduction of the bug
N/A
Please provide the exception or error you saw
Please provide the environment you discovered this bug in
Anything else?
Simple spec file:
Do you want to create a pull request?
No
The text was updated successfully, but these errors were encountered: