timeout.flush()导致单元测试超时(AfterAll失败)

时间:2018-10-05 20:19:34

标签: angularjs unit-testing jasmine mddialog

我正在使用Angular JS 1. *,并使用Jasmine编写单元测试。

<PackageReference Include="StyleCop.Analyzers" Version="1.0.0" PrivateAssets="All" Condition="%(!FileName.Contains('bla.csproj'))" />

// buildCtrl() and stuff ctrl.newPostText = 'My post'; ctrl.submitNewPost(); timeout.flush(); // if I delete this line ctrl.postSubmitting = false // but there's no timeout at least expect(ctrl.postSubmitting).toBe(true); 基本上会启动一个确认submitNewPost,我正在测试中对其进行嘲笑:

mdDialog

您有任何想法如何调试(检查该队列任务)?我可以用什么代替 mdDialogMock = jasmine.createSpyObj('mdDialog', ['confirm', 'show']); mdDialogMock.show.and.returnValue(q.when(true)); mdConfirmDialogMock = jasmine.createSpyObj('mdDialog', [ 'title', 'textContent', 'ok', 'cancel', ]); mdConfirmDialogMock.title.and.returnValue(mdConfirmDialogMock); 使其起作用?

谢谢!

0 个答案:

没有答案