I am writing mocha test cases to test the following steps. I intend to make an API call and wait for 30 minutes before calling another API. I am using an internal node API which was written to call REST APIs to write this test case. But for some reason, setTimeout
is not waiting for the given ms.
Can someone please help me?
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
.....
......
};
});
It does not wait 30 minutes. The call back I put in (the getPC
method) executes immediately.
Any help is appreciated.
Thanks