Typescript 将Jasmine SpyObj Mock转换为Jest Mock
我正在尝试将我的angular项目测试从Jasmine迁移到Jest。在尝试使用TS Jest mocked方法模拟Angularfire firestore类时,我似乎无法正确理解这一点 我使用jasmine的createSpyObj方法多次实现了这一点Typescript 将Jasmine SpyObj Mock转换为Jest Mock,typescript,jestjs,angularfire2,ts-jest,Typescript,Jestjs,Angularfire2,Ts Jest,我正在尝试将我的angular项目测试从Jasmine迁移到Jest。在尝试使用TS Jest mocked方法模拟Angularfire firestore类时,我似乎无法正确理解这一点 我使用jasmine的createSpyObj方法多次实现了这一点 describe('My Example', () => { let firestoreSpy: SpyObj<AngularFirestore>; let firestoreCollectionSpy: S
describe('My Example', () => {
let firestoreSpy: SpyObj<AngularFirestore>;
let firestoreCollectionSpy: SpyObj<AngularFirestoreCollection>;
beforeEach(() => {
firestoreSpy = jasmine.createSpyObj('firestoreSpy', ['collection']);
firestoreCollectionSpy= jasmine.createSpyObj('firestoreCollectionSpy', ['snapshotChanges']);
firestoreSpy.collection.and.returnValue(firestoreCollectionSpy);
});
it('My Test', () => {
// Set the return value of the snapshotChanges method
collectionSpy.snapshotChanges.and.returnValue(of());
};
});
我得到了一个集合的未定义值,它实际上是AngularFirestore类的一个方法
TypeError: Cannot read property 'mockImplementation' of undefined
任何能让我走上正轨的见解都将不胜感激
TypeError: Cannot read property 'mockImplementation' of undefined