Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zone.js: Patched test functions (it, test, describe, etc.) are not used if importing from @jest/globals directly #47603

@dhardtke

Description

@dhardtke

Which @angular/* package(s) are the source of the bug?

zone.js

Is this a regression?

No

Description

If one does not use the globally provided Jest functions like it but instead imports them locally (see ...), then the patch has no effect and zone.js is not working:

import { TestBed, fakeAsync } from '@angular/core/testing';
import { AppComponent } from './app.component';

import { it } from "@jest/globals"; // <- this line leads to the error

describe('AppComponent', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  });

  it('bla', fakeAsync(async () => {
  }));
});

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Expected to be running in 'ProxyZone', but it was not found.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.2.4
Node: 18.10.0 (Unsupported)
Package Manager: npm 8.19.2
OS: win32 x64

Angular: 14.2.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.4
@angular-devkit/build-angular   14.2.4
@angular-devkit/core            14.2.4
@angular-devkit/schematics      14.2.4
@schematics/angular             14.2.4
rxjs                            7.5.7
typescript                      4.7.4

Anything else?

No response

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: testingIssues related to Angular testing features, such as TestBedarea: zonesIssues related to zone.js

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions