-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert: adds rejects() and doesNotReject() #18023
Conversation
lib/assert.js
Outdated
// Asynchronous equivalent of original assert functions. | ||
// Only throws() and doNotThrows() are truely async (all other perform | ||
// synchronous tasks and don't use functions as parameters), but for | ||
// conveniency, the entire API is supported here as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/conveniency/convenience/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 😅
lib/assert.js
Outdated
@@ -306,10 +301,38 @@ assert.doesNotThrow = function doesNotThrow(block, error, message) { | |||
expected: error, | |||
operator: 'doesNotThrow', | |||
message: `Got unwanted exception${details}\n${actual.message}`, | |||
stackStartFn: doesNotThrow | |||
stackStartFn: assert.doesNotThrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name assert.doesNotThrow
as a top level function and reference it directly here to avoid being messed up by monkey-patched assert.doesNotThrow
lib/assert.js
Outdated
@@ -281,16 +274,18 @@ assert.throws = function throws(block, error, message) { | |||
expected: error, | |||
operator: 'throws', | |||
message: `Missing expected exception${details}`, | |||
stackStartFn: throws | |||
stackStartFn: assert.throws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name assert.throws
as a top level function and reference it directly here to avoid being messed up by monkey-patched assert.throws
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
lib/assert.js
Outdated
assert.ok(...args); | ||
} | ||
|
||
Object.assign(promises, assert, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since other assigned APIs do not return promises here:
require('assert').promises.fail().then(() => {}); // does not work
This behavior looks somewhat strange to me..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me as well. I would rather have a dedicated assert.rejects
function. Reject
is used for promises, so this is a good fit out of my perspective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting point.
My intention was to keep the existing behaviour for all assert functions except throws()
and doesNotThrow()
, which are the only two able to run (potentially async) code.
I wouldn't like to force people writing:
const assert = require('assert').promises
await assert(something)
But we can definitely add new functions like reject()
that would be async equivalent of existing one.
Are there any other function you would like to cover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are not talking about redesigning a new assert API here, providing a promisified version of the existing assert APIs is good enough to me. Something like
for (const key of Object.keys(assert)) {
const syncFunc = assert[key];
promises[key] = async function (...args) { return syncFunc(...args) };
}
// override throws later, or in the block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hum, but it's actually what I'd like to avoid.
There's no point making assert.ok()
or assert.fail()
asynchronous. It will make the API more cumbersome to use with no benefit.
It make sense for assert.throws()
and assert.doesNotThrow()
to turn this code (that we used quite a lot in our projects):
it('should report database option errors', async () => {
try {
await transferData({}, '');
throw new Error('it should have failed');
} catch (err) {
assert(err.message.includes('"host" is required'));
}
});
into
it('should report database option errors', async () =>
assert.throws(async () => transferData({}, ''), /^Error: "host" is required/)
);
I don't want to redesign the whole API, but rather wants to support the above.
test/parallel/test-assert.js
Outdated
@@ -750,7 +750,8 @@ common.expectsError( | |||
assert.equal(assert.deepEqual, assert.deepStrictEqual); | |||
assert.equal(assert.notEqual, assert.notStrictEqual); | |||
assert.equal(assert.notDeepEqual, assert.notDeepStrictEqual); | |||
assert.equal(Object.keys(assert).length, Object.keys(a).length); | |||
// strict doesn't expose promises |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, you have currently (all synchronous):
require('assert').equal
require('assert').strict.equal
require('assert').promises.equal
require('assert').promises.strict.equal
I wasn't sure it worth providing require('assert').strict.promises
. Do you think it worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general strict
and regular assert
should have exactly the same API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy that
lib/assert.js
Outdated
assert.ok(...args); | ||
} | ||
|
||
Object.assign(promises, assert, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me as well. I would rather have a dedicated assert.rejects
function. Reject
is used for promises, so this is a good fit out of my perspective.
Because there seems to be a bit of confusion in the discussion: I personally am strongly against adding a new The only thing that should be added out of my perspective are two new functions They behave similar to the current |
@BridgeAR, by bringing But what you suggested above makes more sense, so I'm 100% with you, and implement it if @joyeecheung is happy with it. |
@feugy If adding asynchronous versions of the synchronous APIs doesn't make sense, then maybe we don't even need to add them to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start but I'm also in favour of using rejects
and doesNotReject
instead of a separate promises
namespace.
(Worth noting that this would also be in line with the fact that promises emit unhandledRejection
rather than uncaughtException
.)
lib/assert.js
Outdated
@@ -243,24 +243,17 @@ function expectedException(actual, expected, msg) { | |||
return expected.call({}, actual) === true; | |||
} | |||
|
|||
function getActual(block) { | |||
if (typeof block !== 'function') { | |||
function isFunction(block) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be moved down closer to trySyncBlock
which is its first usage? Or otherwise, move up those two functions here.
I would actually even suggest just inlining this function since it's only used twice. The savings are minimal and now the error thrown will have an extra function in the trace. The latter can be worked around (captureStackTrace) but I don't think it's worth it.
test/parallel/test-assert-async.js
Outdated
|
||
// awaits for async block and catches error | ||
expectThrows(async () => { | ||
await wait(common.platformTimeout(10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the common.platformTimeout
here. Just matters that it's async.
lib/assert.js
Outdated
@@ -333,3 +356,31 @@ assert.strict = Object.assign(strict, assert, { | |||
notDeepEqual: assert.notDeepStrictEqual | |||
}); | |||
assert.strict.strict = assert.strict; | |||
|
|||
// Asynchronous equivalent of original assert functions. | |||
// Only throws() and doNotThrows() are truely async (all other perform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits:
s/doNotThrows()/doesNotThrow()
s/truely/truly
s/other/others
lib/assert.js
Outdated
const actual = getActual(block); | ||
// Shared code for sync and async doesNotThrow(): no-op if actual is undefined. | ||
// Otherwise, produces an AssertionError when actual matches the expected | ||
// message/error class, or let it bubble. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/or let it bubble/or rethrow.
lib/assert.js
Outdated
isFunction(block); | ||
try { | ||
block(); | ||
} catch (actual) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (err)
or catch (e)
is more in line with other usage in the code base.
447adf8
to
c0ba6ad
Compare
Hello gents! What do you think about the latest update? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green
quick fyi... we're not all "gents" :-) |
Sorry, it's bad habit 😓 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it is already looking very promising to me! Just a few small comments :-)
lib/assert.js
Outdated
if (typeof error === 'string') { | ||
if (arguments.length === 3) | ||
if (message !== undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a slightly different behavior as before.
Before assert.throws(() => {}, 'foo', undefined)
would also result in an error. That is not the case anymore with this change. As this is completely independent from the actual change here, I would rather not have this included, especially as I think this should throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right!
To keep this code in an internal function, and not break the existing behaviour, I've used rest params and splat so arguments.length
would still make sense.
lib/assert.js
Outdated
|
||
assert.doesNotThrow = function doesNotThrow(block, error, message) { | ||
const actual = getActual(block); | ||
// Shared code for doesNotThrow() and doesNotReject(): no-op if actual is undefined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is actually not correct anymore as it is only a no-op in case actual
is the sentinel.
I personally feel like it is not necessary to have these comments here because the code is easy to understand but others might disagree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
test/parallel/test-assert-async.js
Outdated
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const promisify = require('util').promisify; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super tiny nit:
Destructuring would be nice as in const { promisify } = require('util')
test/parallel/test-assert-async.js
Outdated
operator: undefined, | ||
actual: undefined, | ||
expected: undefined | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not totally happy with this test as it does not test that the code does not fail sync.
So I would write something like:
assert.doesNotThrow(() => {
assert.rejects(
() => assert.fail(),
common.expectsError({
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'Failed',
operator: undefined,
actual: undefined,
expected: undefined
})
)
});
The same applies to the test below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
test/parallel/test-assert-async.js
Outdated
// awaits for async block | ||
expectsNoRejection(async () => { | ||
await wait(10); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, we do not know if these really work because the function itself might theoretically execute sync.
So a better test out of my perspective would be:
let promise;
let threw = false;
try {
promise = assert.doesNotReject(async () => {
await wait(10);
assert.fail();
});
} catch (err) {
threw = true;
}
assert.strictEqual(threw, false);
assert.rejects(() => promise,
common.expectsError({
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'Got unwanted exception ... '
...
})
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
test/parallel/test-assert-async.js
Outdated
const promisify = require('util').promisify; | ||
const wait = promisify(setTimeout); | ||
|
||
// Ensure async support for assert.rejects() and assert.doesNotReject() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I would say it tests the functionality of assert.rejects()
and assert.doesNotReject()
but not that it "ensures" async support for those as they should always be async.
I would describe it as e.g. "Tests assert.rejects()
and assert.doesNotReject()
by checking their expected output and by verifying that they do not work sync."
lib/assert.js
Outdated
} | ||
|
||
assert.throws = function throws(block, error, message) { | ||
expectsError(getActual(block), error, message, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit surprised that this
for the stackStartFn
shall work. this
should normally refer to either assert.ok
or assert.strict
.
Can you please write a test for this as well if none exist? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test, and you were absolutely right.
Providing explicit values keeps the existing stack-traces:
6cdbbe6
to
6779293
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change itself looks very good now! Just the tests might need a bit more polishing :-)
lib/assert.js
Outdated
}; | ||
|
||
assert.doesNotReject = async function doesNotReject(block, ...args) { | ||
expectsNoError(assert.doesNotReject, await waitForActual(block), ...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super super tiny nit: you can actually access the own function without assert
. It would just save some characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also keep you away from monkey-patching. I would prefer referencing it directly here.
test/parallel/test-assert-async.js
Outdated
} catch (err) { | ||
const lines = err.stack.split('\n') | ||
assert.equal(lines.length, 6) | ||
assert.ok(lines[0].includes('Missing expected exception')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be really nice if the error message is changed to Missing expected rejection
.
test/parallel/test-assert-async.js
Outdated
assert.ok(lines[0].includes('Got unwanted exception')) | ||
assert.ok(lines[2].includes('Object.<anonymous>')) | ||
assert.ok(lines[2].includes('test-assert-async.js')) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two tests above are already tested for in test-assert.js
. This adds the check for the error stack, so it indeed tests something new, but in that case I would rather replace the ones in test-assert.js
with these tests instead of "duplicating" them.
test/parallel/test-assert-async.js
Outdated
} | ||
|
||
try { | ||
await assert.doesNotReject(() => Promise.reject()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the same as https://github.com/nodejs/node/pull/18023/files#diff-cdf49dc677a8ea6f00de9f95639355e8R44.
What was not yet tested for is if the functions throws sync.
test/parallel/test-assert-async.js
Outdated
assert.ok(lines[0].includes('Got unwanted exception')) | ||
assert.ok(lines[2].includes('<anonymous>')) | ||
} | ||
})() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a async function as wrapper will actually hide if the function is executed sync or async. So I would just use the pattern as above without the async wrapper.
@feugy thanks a lot for being so patient! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lib/assert.js
Outdated
}; | ||
|
||
assert.doesNotReject = async function doesNotReject(block, ...args) { | ||
expectsNoError(assert.doesNotReject, await waitForActual(block), ...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also keep you away from monkey-patching. I would prefer referencing it directly here.
LGTM with @BridgeAR 's comments addressed |
6779293
to
4f2a349
Compare
doc/api/assert.md
Outdated
SyntaxError | ||
); | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the next lines (copied from assert.doesNotThrow()
doc) may be skipped in favour of a reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I would actually even go so far and remove everything from here on. A text like:
Besides the async nature to await the completion it behaves identical to `assert.doesNotThrow()`.
Keep an example with async await and also maybe add a example using promises.
The same can be applied to the reject
function.
lib/assert.js
Outdated
operator: stackStartFn.name, | ||
message: `Missing expected ${stackStartFn === rejects | ||
? 'rejection' | ||
: 'exception'}${details}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator
& message
will now contain appropriate values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the unwritten rule to not use multi line template strings in Node.js. This does look somewhat elegant but it is probably best to just have something like: Missing expected ${fnType}${details}
.
test/parallel/test-assert.js
Outdated
e => { | ||
assert.strictEqual(e.code, 'ERR_ASSERTION'); | ||
assert(/^Missing expected exception\.$/.test(e.message)); | ||
assert.strictEqual(e.operator, 'throws'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't confident to replace common.expectsError()
with such custom assertions, but couldn't find a better way to reuse the existing test, as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually just keep this as is and just add a single line to one of the existing tests that checks for assert.ok(!err.stack.includes('at throws')
.
doc/api/assert.md
Outdated
|
||
> Stability: 1 - Experimental | ||
|
||
Awaits for the promise returned by function `block` to complete and not be rejected. See [`assert.rejects()`][] for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exceeds 80 characters.
expectsError(throws, getActual(block), ...args); | ||
} | ||
|
||
assert.throws = throws; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (non-blocking): I personally prefer the following to save lines:
assert.throws = function throws(block, ...args) {
expectsError(throws, getActual(block), ...args);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. We could check for the function name instead but that could theoretically be manipulated.
So just keep it as is. Thanks for the heads up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, while looking at the code again: we actually already use the function name and do not strictly test if it it a "valid" function. So we could indeed just switch to name checking only.
doc/api/assert.md
Outdated
SyntaxError | ||
); | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I would actually even go so far and remove everything from here on. A text like:
Besides the async nature to await the completion it behaves identical to `assert.doesNotThrow()`.
Keep an example with async await and also maybe add a example using promises.
The same can be applied to the reject
function.
lib/assert.js
Outdated
operator: stackStartFn.name, | ||
message: `Missing expected ${stackStartFn === rejects | ||
? 'rejection' | ||
: 'exception'}${details}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the unwritten rule to not use multi line template strings in Node.js. This does look somewhat elegant but it is probably best to just have something like: Missing expected ${fnType}${details}
.
test/parallel/test-assert-async.js
Outdated
} | ||
assert.strictEqual(threw, false); | ||
assert.rejects(() => promise, | ||
err => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am relatively certain that this is going to trigger a lint error. The err
should probably be in parentheses. The same applies to the test below.
test/parallel/test-assert-async.js
Outdated
} catch (err) { | ||
threw = true; | ||
} | ||
assert.strictEqual(threw, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about this again, the try catch and the threw is not necessary here at all. If the promise throws the test would fail right away. threw
is only necessary for tests that check for threw === true
. So the tests can be much smaller (I know I originally suggested this pattern).
test/parallel/test-assert-async.js
Outdated
message: 'Failed' | ||
}) | ||
) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrapper is not needed as the test would fail right away if assert.rejects
would fail.
test/parallel/test-assert-async.js
Outdated
) | ||
}); | ||
|
||
assert.doesNotThrow(() => assert.doesNotReject(() => {})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrapper is not needed due to the reason mentioned above.
test/parallel/test-assert.js
Outdated
e => { | ||
assert.strictEqual(e.code, 'ERR_ASSERTION'); | ||
assert(/^Missing expected exception\.$/.test(e.message)); | ||
assert.strictEqual(e.operator, 'throws'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually just keep this as is and just add a single line to one of the existing tests that checks for assert.ok(!err.stack.includes('at throws')
.
test/parallel/test-assert.js
Outdated
const lines = e.stack.split('\n') | ||
assert.equal(lines.length, 11) | ||
assert.ok(lines[0].includes(e.message)) | ||
assert.ok(lines[1].includes('at assert.throws')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I am not certain if that is actually true? I thought that frame would actually be excluded? Do the tests pass?
4f2a349
to
556ecdc
Compare
@BridgeAR It seems to me like rejections have slightly different semantics than |
@apapirovski I agree that it is not exactly the same but the reason for that is that we have another issue that has to be solved as well. See #15126. |
@BridgeAR Yeah, I'm aware and have dug around in that PR, actually, but that code will take a while to land given the performance implications. I'm not really certain we have a great path forward that doesn't impact performance. Maybe I'm wrong... (I have some thoughts on how to do it without all of the C++ boundary crossing but only theoretical atm.) |
@BridgeAR given that this is only semver-minor whereas any changes to uncaught Promise handling would be semver-major, do you think it would be ok to land as is? Especially in the light of the recent rejection of the |
@apapirovski yes, I am now ok with landing it as is. I will open another PR to add a comment to it similar to @feugy thanks a lot for your work and for being patient :) |
It's all fine! |
Implement asynchronous equivalent for assert.throws() and assert.doesNotThrow().
0a031d0
to
7a94ce8
Compare
And done! What's next? |
Implement asynchronous equivalent for assert.throws() and assert.doesNotThrow(). PR-URL: nodejs#18023 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Landed in 599337f 🎉 I removed the |
Should this be backported to |
If this gets backported, it should be backported at the same time as #19650 (possibly in the same commit). |
Implement asynchronous equivalent for assert.throws() and assert.doesNotThrow(). PR-URL: nodejs#18023 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Implement asynchronous equivalent for assert.throws() and assert.doesNotThrow(). PR-URL: nodejs#18023 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Implement asynchronous equivalent for assert.throws() and assert.doesNotThrow(). PR-URL: nodejs#18023 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Implement asynchronous equivalent for assert.throws() and assert.doesNotThrow(). Backport-PR-URL: #24019 PR-URL: #18023 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Implement async equivalent of
assert.throws()
andassert.doesNotThrow()
.This PR is a follow-up of #17843, but takes into account James' suggestion to bring this as experimental feature, without change the existing API.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
assert