Reputation: 240
I feel like this has been asked many times, but none of the solutions I find is helping and I'm a bit lost what is the cause of my issue. The solutions usually suggest that either the async/fakeAsync call was set in the wrong place (e.g. describe instead of beforeEach) or to remove the async completely but non of that is working and as this is a plain generated test I would expect it to just run.
So, no matter what test case I want to run I'm facing the following issue:
Error: Expected to be running in 'ProxyZone', but it was not found.
at Function.assertPresent (node_modules/zone.js/dist/zone-testing.js:215:23)
at Object.resetFakeAsyncZone (node_modules/zone.js/dist/zone-testing.js:1997:54)
at resetFakeAsyncZone (packages/core/testing/src/fake_async.ts:23:32)
at UserContext.<anonymous> (packages/core/testing/src/before_each.ts:26:5)
at <Jasmine>
I tried that with a completely empty and freshly generated component, where the test case is auto generated by the cli and it fails as well. Here is the test-case component test:
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TestCaseComponent } from './test-case.component';
describe('TestCaseComponent', () => {
let component: TestCaseComponent;
let fixture: ComponentFixture<TestCaseComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ TestCaseComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(TestCaseComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
I run the test with the following command:
ng test --include=**/test-case.component.spec.ts
I'm using the zone.js version 0.11.4
Upvotes: 1
Views: 3629
Reputation: 240
Well just that I posted my question here I figured it out... During one of the several attempts to solve the issue I added this line
import 'zone.js/dist/zone-testing.js'
to my pollyfills.ts file.
However it seems not to be needed here and has to be added at the very beginning of the test.ts file.
Upvotes: 2