Kha*_*ara 4 typescript jestjs angular
我正在尝试使用 jest 编写 Angular 测试:
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [BookListComponent],
}).compileComponents();
}));
Run Code Online (Sandbox Code Playgroud)
当我启动时:
npm run test:watch
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
错误 TS2304:C 找不到名称“async”。
你必须更改async为waitForAsyncAngular 11,因为他们更改了它。他们更改了它,因为async您在以前的版本中导入的内容@angular/core/testing与 JavaScript 的本机类似async,可能会导致混乱。
import { waitForAsync } from '@angular/core/testing';
.....
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [BookListComponent],
}).compileComponents();
}));
Run Code Online (Sandbox Code Playgroud)
waitForAsync的链接。
| 归档时间: |
|
| 查看次数: |
3065 次 |
| 最近记录: |