gpt4 book ai didi

node.js - 监视 Date.now() 导致 jasmine-node 没有响应

转载 作者:太空宇宙 更新时间:2023-11-03 22:47:43 24 4
gpt4 key购买 nike

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

spyOn(Date, 'now').andReturn(1387636363717); //always return a fixed time

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

最佳答案

我写了一个小测试。它工作得很好。在版本 1.11.0 中使用 jasmin-node。

那么您的 Date.now 函数在哪里使用?

spyOn(Date, 'now').andReturn(1387636363717);
expect(Date.now()).toEqual(1387636363717);

关于node.js - 监视 Date.now() 导致 jasmine-node 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20720147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com