使用 Angular 8、@angular-builders/jest 8.0.2、jest 24.8,并给出以下测试通过
import { tick, fakeAsync } from '@angular/core/testing';
it('test 1000 milliseconds', fakeAsync(() => {
const fn = jest.fn();
setTimeout(() => {
fn();
}, 1000);
tick(999);
expect(fn).not.toHaveBeenCalled();
tick(1);
expect(fn).toHaveBeenCalled();
}));
我想写几个类似的测试使用it.each
it.each([[1000], [2000], [3000]])(
'test %d milliseconds',
fakeAsync(milliseconds => {
const fn = jest.fn();
setTimeout(() => {
fn();
}, milliseconds);
tick(milliseconds - 1);
expect(fn).not.toHaveBeenCalled();
tick(1);
expect(fn).toHaveBeenCalled();
}),
);
但我在每次测试中都遇到了这个错误:
Expected to be running in 'ProxyZone', but it was not found.
at Function.Object.<anonymous>.ProxyZoneSpec.assertPresent (node_modules/zone.js/dist/proxy.js:42:19)
at node_modules/zone.js/dist/fake-async-test.js:588:47
我错过了什么?