【发布时间】:2015-07-02 05:11:31
【问题描述】:
我正在编写 mocha 测试用例来测试以下步骤。我打算进行 API 调用并等待 30 分钟,然后再调用另一个 API。我正在使用一个内部节点 API,它是为了调用 REST API 来编写这个测试用例而编写的。但由于某种原因,setTimeout 没有等待给定的 ms。
有人可以帮我吗?
describe('Checkout - ', function() {
before(function() {
lapetus = test.Lapetus;
});
it('Get purchase contract after session is expired [C123]', function(done) {
this.timeout(180000000);
lapetus.run(function() {
// create customer
......
// create new cart and add one item
......
// create new contract with empty cart id
.......
var pc_id =....;
// wait for 30 minutes for the session to expire
console.log('wait... ' + new Date);
this.setTimeout(getPC(lapetus,pc_id), 18000000);
console.log('ok... ' + new Date);
done();
});
});
var getPC = function(lapetus, pc_id){
// get newly created purchase contract and verify session expired message throws
.....
......
};
});
它不会等待 30 分钟。我输入的回调(getPC 方法)立即执行。
感谢任何帮助。
谢谢
【问题讨论】:
标签: javascript node.js settimeout