I am new with the unit test of angular and i am using jest, I install it with ng add @briebug/jest-schematic. When run npm test (jest) in a base project throws the next error
FAIL src/app/app.component.spec.ts (7.418 s)
AppComponent
✕ should create the app (6 ms)
● AppComponent › should create the app
zone-testing.js is needed for the fakeAsync() test helper but could not be found.
Please make sure that your environment includes zone.js/testing
at resetFakeAsyncZone (../packages/core/testing/src/fake_async.ts:25:9)
at Object.<anonymous> (../packages/core/testing/src/test_hooks.ts:39:7)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
at runJest (node_modules/@jest/core/build/runJest.js:387:19)
at _run10000 (node_modules/@jest/core/build/cli/index.js:408:7)
at runCLI (node_modules/@jest/core/build/cli/index.js:261:3)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 9.579 s
How to resolve this problem, thanks and here is the app component.spec
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
});