我正在运行Jasmine npm 2.5.3,并通过网络浏览器运行单元测试。 Spec Runner正在测试多个JS文件,当我运行所有测试时,我得到一个失败的测试,它显示测试的名称在一个完全不同的文件中,而不是显示的堆栈跟踪。
以下是堆栈跟踪中的代码:
这是失败的
expect(get).toHaveBeenCalledTimes(expectedCalls);
线。
如果我一次运行一个测试,没有问题。我确实知道如果我将错误的行更改为不直接引用间谍,则没有问题:
expect(webApi[spyFunctionName]).toHaveBeenCalledTimes(expectedCalls);
我认为期望(get)和expect(webApi [spyFunctionName]))在这种情况下是等效的。 我不明白间谍是如何工作的,还是我偶然发现了一个错误?
以下是堆栈跟踪以防有用:
Expected spy GetList to have been called 0 times. It was called 1 times.
at stack (http://localhost:1130/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1640:17)
at buildExpectationResult (http://localhost:1130/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1610:14)
at Spec.expectationResultFactory (http://localhost:1130/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:655:18)
at Spec.addExpectationResult (http://localhost:1130/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:342:34)
at Expectation.addExpectationResult (http://localhost:1130/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:599:21)
at Expectation.toHaveBeenCalledTimes (http://localhost:1130/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1564:12)
at http://localhost:1130/test/spec/Allgnt.RestLibSpec.js:166:34