after(async function () {
clock.uninstall()
await sleep(5000)
})
Despite asserting that the promise rejects within the test, the promise rejects after the test as well. Not entirely sure why this happening.
Tried manually wrapping in try-catch with an await instead of assert.rejects and it still fails.
Tried wrapping the promise in another promise before passing to assert.rejects.
Solution
What does appear to work, is manually handling the callback of the promise. That is, explicitly defining a then and catch method to assert the rejection, and awaiting the promise at the end of the test to ensure it resolves before the test finishes. Not sure why this works, but I am unable to reproduce the error with this change.
Problem
https://github.com/aws/aws-toolkit-vscode/issues/6043 To reproduce, add a 5 second delay to the
after
hook at the top level. One way to do this is to insert this at line 84.Despite asserting that the promise rejects within the test, the promise rejects after the test as well. Not entirely sure why this happening.
await
instead ofassert.rejects
and it still fails.assert.rejects
.Solution
What does appear to work, is manually handling the callback of the promise. That is, explicitly defining a
then
andcatch
method to assert the rejection, and awaiting the promise at the end of the test to ensure it resolves before the test finishes. Not sure why this works, but I am unable to reproduce the error with this change.Notes
assert.rejects
implementation: https://github.com/nodejs/node/blob/3178a762d6a2b1a37b74f02266eea0f3d86603be/lib/assert.js#L653. Doesn't appear to be the problem because the same is observed when manually wrapping.await
docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/awaitLicense: I confirm that my contribution is made under the terms of the Apache 2.0 license.