Ana*_*and 2 ngrx-effects angular jasmine-marbles angular7
尝试对现有的和最近迁移的Angular 7项目运行简单的效果测试。但是我得到如下错误。
错误:未 在新TestHotObservable(node_modules / jasmine-marbles / es6 / src / test-observables.js:21:39)的getTestScheduler(node_modules / jasmine-marbles / es6 / src / scheduler.js:11:1)初始化任何测试计划程序)在Module.hot(node_modules / jasmine-marbles / es6 / index.js:7:1)
我的效果规范文件中的代码是茉莉花大理石的基本标准检查。
const action = new Load(request);
const completion = new LoadSuccess(result);
actions$ = hot('-a-', { a: action});
const response = cold('-a|', {a: result});
const expected = cold('--b', {b: completion});
service.getSomething.and.returnValue(result);
expect(effects.load$).toBeObservable(expected);
Run Code Online (Sandbox Code Playgroud)
有人看过并解决过此错误吗?
尽管更改为ES5可以解决问题,但我的同事还是提出了一个更好的解决方案。解决方案是在src / test.ts文件中添加以下行。我更喜欢它,因为它可以继续在ES6中进行测试。
import { addMatchers, getTestScheduler, initTestScheduler, resetTestScheduler } from 'jasmine-marbles';
// configure matchers for jasmine-marbles
jasmine.getEnv().beforeAll(() => {
return addMatchers();
});
jasmine.getEnv().beforeEach(() => {
initTestScheduler();
});
jasmine.getEnv().afterEach(() => {
getTestScheduler().flush();
resetTestScheduler();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
788 次 |
| 最近记录: |