Angular 有棱角的8,开玩笑-';茉莉花&x27;没有导出的成员';SpyObj';

Angular 有棱角的8,开玩笑-';茉莉花&x27;没有导出的成员';SpyObj';,angular,jasmine,jestjs,angular-cli,angular-jest,Angular,Jasmine,Jestjs,Angular Cli,Angular Jest,我有一个Angular CLI项目,它具有默认的Karma测试运行程序。 我曾经用玩笑来代替因果报应,并注意到一些测试通过了一些失败 例如,在测试级别声明变量: let mockObj: jasmine.SpyObj<MyClass>; 当你选择开玩笑时,你必须使用开玩笑的间谍和嘲弄,而不是茉莉花间谍。或者其他类似的测试双库 开玩笑的例子 从“/sound player”导入SoundPlayer; const mockPlaySoundFile=jest.fn(); 笑话.模仿(

我有一个Angular CLI项目,它具有默认的Karma测试运行程序。 我曾经用玩笑来代替因果报应,并注意到一些测试通过了一些失败

例如,在测试级别声明变量:

let mockObj: jasmine.SpyObj<MyClass>;

当你选择开玩笑时,你必须使用开玩笑的间谍和嘲弄,而不是茉莉花间谍。或者其他类似的测试双库

开玩笑的例子

从“/sound player”导入SoundPlayer;
const mockPlaySoundFile=jest.fn();
笑话.模仿('./声音播放器',()=>{
返回jest.fn().mockImplementation(()=>{
返回{playSoundFile:mockPlaySoundFile};
});
});
在每个之前(()=>{
SoundPlayer.mockClear();
mockPlaySoundFile.mockClear();
});
它('消费者应该能够在SoundPlayer上调用new(),()=>{
const soundPlayerConsumer=新的soundPlayerConsumer();
//确保构造函数创建了对象:
expect(soundPlayerConsumer.toBeTruthy();
});
它('我们可以检查使用者是否调用了类构造函数',()=>{
const soundPlayerConsumer=新的soundPlayerConsumer();
期望(声音播放器)。获得足够的时间(1);
});
它('我们可以检查使用者是否调用了类实例上的方法',()=>{
const soundPlayerConsumer=新的soundPlayerConsumer();
const coolSoundFileName='song.mp3';
soundPlayerConsumer.playSomethingCool();
expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
});
error `"Namespace 'jasmine' has no exported member 'SpyObj'`
@angular-builders/jest: "^8.3.2"
jest: "^24.9.0"
jasmine-core: "3.5.0"
@types/jest: "^24.9.0"
@types/jasmine: "3.5.0"
@types/jasminewd2": "2.0.8"