AsyncTestZoneSpec is needed for the async - Angular

I had the same problem with with the spectator testing framework.

The solution was, to import jest-preset-angular before the spectator imports.

wrong:


import { defineGlobalsInjections } from '@ngneat/spectator';
import 'jest-preset-angular';

correct:


import 'jest-preset-angular';
import { defineGlobalsInjections } from '@ngneat/spectator';


The following command was likely deprecated:

ng test --main somecomponent.spec.ts

Instead, use:

ng test

To just run a specific spec instead of all, prefix your describe and it block with f:

fdescribe('whatever', () => {})

I use this command in order to test one file only:

ng test --include somecomponent.spec.ts

You are going to have issues with the --main option as @clean-code has stated.


I was getting this error after Angular 11 upgrade.

This line must be the first line in test.ts, before all other imports:

import 'zone.js/dist/zone-testing'; // zone-testing needs to be first import!