我正在将旧组件从 Typescript 6 更新到 8。我已经更新了 中的 Jasmine 依赖项package.json,但现在出现错误:
“以下标识符的定义与另一个文件中的定义冲突:
ImplementationCallback、ExpectedRecursive、Expected、SpyObjMethodNames、CustomEqualityTester、CustomMatcherFactory、ExpectationFailed、SpecFunction、SpyObj、jasmine”。
两个冲突的文件如下:
@types/jasmine/index.d.ts
@types/jasmine/ts3.1/index.d.ts
Run Code Online (Sandbox Code Playgroud)
我已经尝试删除缓存以及删除 node_modules 和 package-lock 然后重新安装所有内容。我尝试删除其中一个文件并将另一个文件用作唯一的 index.d.ts 文件,但随后出现错误“找不到 'jasmine' 的类型定义文件。”
有没有人有其他建议?
我有必须期待的规范,它仍然说没有期望......
it('should click on yes button of technician and check save&continue functionality', () => {
const saveAndContinue = fixture.debugElement.query(By.css(saveContinueBtn)).nativeElement;
saveAndContinue.click();
fixture.detectChanges();
fixture.whenStable().then(() => {
const spy = spyOn(component,'isSaveAndContinueClicked').and.callThrough();
expect(component).toBeDefined();
expect(spy);
component.isSaveAndContinueClicked();
expect(component.isSaveAndContinueClicked).toHaveBeenCalled();
const yesbutton = fixture.debugElement.query(By.css('#yesButton')).nativeElement;
expect(yesbutton).toBeTruthy();
fixture.detectChanges();
fixture.whenStable().then(() => {
spyOn(component, 'change').and.callThrough();
spyOn(component, 'change2').and.callThrough();
yesbutton.click();
expect(component.change).toHaveBeenCalled();
expect(component.change2).toHaveBeenCalled();
});
});
});
Run Code Online (Sandbox Code Playgroud)
它抛出错误,因为规范 testComponent 应该点击技术人员的“是”按钮并检查保存和继续功能没有期望......你能建议......