间谍日期.now()导致jasmine-node没有响应

Shu*_*ing 1 unit-testing mocking node.js jasmine jasmine-node

我正在使用jasmine-node进行单元测试.我做了以下代码来模拟Date.now()

spyOn(Date, 'now').andReturn(1387636363717); //always return a fixed time
Run Code Online (Sandbox Code Playgroud)

然后我试图运行jasmine-node spec/但它没有输出就停止了工作.我无法弄清楚是什么原因.

小智 5

我写了一个很小的考试.它工作得很好.在1.11.0版中使用jasmin-node.

你的Date.now函数在哪里使用?

spyOn(Date, 'now').andReturn(1387636363717);
expect(Date.now()).toEqual(1387636363717);
Run Code Online (Sandbox Code Playgroud)