dcp*_*450 6 unit-testing angular-cli angular
从 v8 升级到 v9 后,我已经更新并通过了所有单元测试。但是,现在我收到以下错误:
Cannot set base providers because it has already been called
研究表明我在申请中打过两次电话BrowserDynamicTestingModule。platformBrowserDynamicTesting()我搜索了整个应用程序,只在我的test.ts文件中找到了一次:
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
declare const require: {
context(
path: string,
deep?: boolean,
filter?: RegExp
): {
keys(): string[];
<T>(id: string): T;
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
Run Code Online (Sandbox Code Playgroud)
我不确定错误还可能来自哪里。
| 归档时间: |
|
| 查看次数: |
1276 次 |
| 最近记录: |