I've got all of my unit tests updated and passing after an upgrade from v8 to v9. However, now I'm getting the following error:
Cannot set base providers because it has already been called
Research suggested that I had BrowserDynamicTestingModule or platformBrowserDynamicTesting() called twice in my application. I searched my whole app and only found them once in my test.ts file:
// 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);
I'm not sure where else the error could come from.