Skip to content
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

[v8.x] backport assert: add rejects() and doesNotReject() #24019

Closed

Conversation

MylesBorins
Copy link
Contributor

Implement asynchronous equivalent for assert.throws() and
assert.doesNotThrow().

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added assert Issues and PRs related to the assert subsystem. v8.x labels Nov 1, 2018
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>
@MylesBorins MylesBorins added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 1, 2018
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BridgeAR
Copy link
Member

BridgeAR commented Nov 1, 2018

@MylesBorins thanks a lot! 👍

@MylesBorins
Copy link
Contributor Author

@BridgeAR are there any other semver-minor changes to assert we should look at backporting for the next 8.x?

@not-an-aardvark
Copy link
Contributor

It would probably be worth also backporting the two commits from #19650 at the same time, since they modified the assert.rejects API. The unmodified version of the API from #18023 never appeared in a release (see the note at the top of #19650 for more info).

This updates the test in `test/parallel/test-assert-async.js` to add an
assertion that the Promises used in the test end up fulfilled.
Previously, if an assertion failure occurred, the Promises would have
rejected and a warning would have been logged, but the test would still
have exit code 0.

PR-URL: nodejs#19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.

Fixes: nodejs#19646
PR-URL: nodejs#19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins
Copy link
Contributor Author

@MylesBorins
Copy link
Contributor Author

one more ci... should be working now

https://ci.nodejs.org/job/node-test-pull-request/18309/

@MylesBorins
Copy link
Contributor Author

landed in 7f34c27...0d241ba

@MylesBorins MylesBorins closed this Nov 4, 2018
MylesBorins pushed a commit that referenced this pull request Nov 4, 2018
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>
MylesBorins pushed a commit that referenced this pull request Nov 4, 2018
This updates the test in `test/parallel/test-assert-async.js` to add an
assertion that the Promises used in the test end up fulfilled.
Previously, if an assertion failure occurred, the Promises would have
rejected and a warning would have been logged, but the test would still
have exit code 0.

Backport-PR-URL: #24019
PR-URL: #19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins pushed a commit that referenced this pull request Nov 4, 2018
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.

Fixes: #19646
Backport-PR-URL: #24019
PR-URL: #19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants