Call $DONE function exactly once per test

Also make a note in CONTRIBUTING.md that `$DONE` shouldn't be called multiple times.
This commit is contained in:
André Bargull 2019-07-22 02:12:24 -07:00
parent 64b6b844eb
commit d8c20b423b
5 changed files with 2 additions and 6 deletions

View File

@ -298,7 +298,7 @@ Consumers that violate the spec by throwing exceptions for parsing errors at run
## Writing Asynchronous Tests
An asynchronous test is any test that include the `async` frontmatter flag. When executing such tests, the runner expects that the global `$DONE()` function will be called to signal test completion.
An asynchronous test is any test that include the `async` frontmatter flag. When executing such tests, the runner expects that the global `$DONE()` function will be called **exactly once** to signal test completion.
* If the argument to `$DONE` is omitted, is `undefined`, or is any other falsy value, the test is considered to have passed.

View File

@ -43,5 +43,4 @@ Promise.allSettled([thenable])
assert.sameValue(settleds.length, 1);
assert.sameValue(settleds[0].status, 'rejected');
assert.sameValue(settleds[0].reason, simulation);
$DONE();
}).then($DONE, $DONE);

View File

@ -49,5 +49,4 @@ Promise.allSettled([fulfiller, rejector])
assert.sameValue(settleds[0].value, 42);
assert.sameValue(settleds[1].status, 'fulfilled');
assert.sameValue(settleds[1].value, simulation);
$DONE();
}).then($DONE, $DONE);

View File

@ -40,5 +40,4 @@ Promise.allSettled([fulfiller, lateRejector])
assert.sameValue(settleds[0].value, 42);
assert.sameValue(settleds[1].status, 'fulfilled');
assert.sameValue(settleds[1].value, simulation);
$DONE();
}).then($DONE, $DONE);

View File

@ -27,5 +27,4 @@ var thenable = {
Promise.allSettled([thenable])
.then((settleds) => {
checkSettledPromises(settleds, [{ status: 'rejected', reason: simulation }]);
$DONE();
}).then($DONE, $DONE);