问题可能出现在测试用例中的 TestBed 配置设置上。按照以下步骤进行修复:
import { TestBed } from '@angular/core/testing';
替换为:
import { TestBed } from '@angular/platform-browser/testing';
import { MyComponent } from './my.component';
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ /* any other modules needed for your tests */ ],
declarations: [ MyComponent ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ] // If you're using custom elements
})
.compileComponents();
}));
按照上述步骤重新构建测试用例,这应该可以解决 Karma/Jasmine 测试在更新 Angular 版本后出现的问题。