diff --git a/src/models/Spec.d.ts b/src/models/Spec.d.ts index cbcb585..4bc4967 100644 --- a/src/models/Spec.d.ts +++ b/src/models/Spec.d.ts @@ -461,7 +461,7 @@ declare class Spec { * sleep after spec execution * @see https://pactumjs.github.io/api/utils/sleep.html */ - sleep(ms: number): Promise; + sleep(ms: number): Spec; } declare namespace Spec { } diff --git a/src/models/Tosser.js b/src/models/Tosser.js index 6a74a8f..5cca5ca 100644 --- a/src/models/Tosser.js +++ b/src/models/Tosser.js @@ -51,7 +51,7 @@ class Tosser { } return th.getOutput(this.spec, this.spec._returns); } finally { - this.sleep !== "" && await helper.sleep(this.sleep); + this.sleep > 0 && await helper.sleep(this.sleep); await this.removeInteractionsFromServer(); this.setPreviousLogLevel(); } diff --git a/test/component/bdd.spec.js b/test/component/bdd.spec.js index ff3f19f..95b7307 100644 --- a/test/component/bdd.spec.js +++ b/test/component/bdd.spec.js @@ -181,7 +181,7 @@ describe('BDD', () => { it('Should sleep after spec', async () => { const spec = pactum.spec(); spec.useInteraction('default get'); - await spec.get('http://localhost:9393/default/get').expectStatus(200).sleep(2000).toss(); + await spec.get('http://localhost:9393/default/get').expectStatus(200).sleep(10).toss(); }); }); diff --git a/test/component/spec.handler.spec.js b/test/component/spec.handler.spec.js index 68bf141..bc34d00 100644 --- a/test/component/spec.handler.spec.js +++ b/test/component/spec.handler.spec.js @@ -94,6 +94,6 @@ describe('Spec Handler', () => { id: 2 } ]) - .sleep(2000); + .sleep(10); }); }); \ No newline at end of file