42 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Starting from Mocha v3.0.0, calling ``++this.timeout(X)++`` with ``++X++`` greater than the https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value[maximum delay value] (2,147,483,647 ms) https://mochajs.org/#hook-level[will cause the timeout to be disabled]. This might not be what the developer intended. If the goal is really to disable the timeout, ``++this.timeout(0)++`` should be used instead.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
describe("testing this.timeout", function() {
it("unexpectedly disables the timeout", function(done) {
this.timeout(2147483648); // Noncompliant
});
});
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
describe("testing this.timeout", function() {
it("doesn't disable the timeout", function(done) {
this.timeout(1000);
});
});
----
Or if you meant to disable the timeout
----
describe("testing this.timeout", function() {
it("disables the timeout as expected", function(done) {
this.timeout(0);
});
});
----
2021-04-28 16:49:39 +02:00
== See
* https://mochajs.org/#hook-level[Mocha documentation]