[Unit test] jasmine createSpyObj
Posted answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Unit test] jasmine createSpyObj相关的知识,希望对你有一定的参考价值。
beforeEach(() => { contextStub = { debug: false, engine: jasmine.createSpyObj(‘engine‘, [ ‘createCollection‘, ‘createContext‘, ‘createSchematic‘, ‘createSourceFromUrl‘, ‘transformOptions‘, ‘executePostTasks‘ ]), logger: jasmine.createSpyObj(‘logger‘, [‘info‘]), schematic: jasmine.createSpyObj(‘schematic‘, [‘call‘]), strategy: 0, interactive: false, addTask: jasmine.createSpy() }; }); it(‘schedules an npm install task if Material is not installed‘, () => { const rule = installMaterial(); rule(testTree, contextStub); expect(contextStub.addTask).toHaveBeenCalled(); expect(contextStub.logger.info).toHaveBeenCalledWith(‘Installing Angular Material...‘); });
以上是关于[Unit test] jasmine createSpyObj的主要内容,如果未能解决你的问题,请参考以下文章
Writing Jasmine Unit Tests In ES6
在Jasmine Unit Test中为PhantomJS配置浏览器语言
如何为combineLatest rxjs Angular编写Jasmine Unit测试用例