test: refactor common.expectsError#31092
Closed
BridgeAR wants to merge 2 commits intonodejs:masterfrom
Closed
Conversation
This completely refactors the `expectsError` behavior: so far it's almost identical to `assert.throws(fn, object)` in case it was used with a function as first argument. It had a magical property check that allowed to verify a functions `type` in case `type` was passed used in the validation object. This pattern is now completely removed and `assert.throws()` should be used instead. The main intent for `common.expectsError()` is to verify error cases for callback based APIs. This is now more flexible by accepting all validation possibilites that `assert.throws()` accepts as well. No magical properties exist anymore. This reduces surprising behavior for developers who are not used to the Node.js core code base. This has the side effect that `common` is used significantly less frequent.
Collaborator
Collaborator
Trott
approved these changes
Dec 26, 2019
jasnell
approved these changes
Dec 26, 2019
Collaborator
trivikr
approved these changes
Dec 29, 2019
BridgeAR
added a commit
that referenced
this pull request
Dec 31, 2019
This completely refactors the `expectsError` behavior: so far it's almost identical to `assert.throws(fn, object)` in case it was used with a function as first argument. It had a magical property check that allowed to verify a functions `type` in case `type` was passed used in the validation object. This pattern is now completely removed and `assert.throws()` should be used instead. The main intent for `common.expectsError()` is to verify error cases for callback based APIs. This is now more flexible by accepting all validation possibilites that `assert.throws()` accepts as well. No magical properties exist anymore. This reduces surprising behavior for developers who are not used to the Node.js core code base. This has the side effect that `common` is used significantly less frequent. PR-URL: #31092 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Member
Author
|
Landed in e038d6a 🎉 |
cjihrig
added a commit
to cjihrig/node
that referenced
this pull request
Dec 31, 2019
This custom ESLint rule is unused since nodejs#31092. This commit removes it.
2 tasks
Trott
pushed a commit
that referenced
this pull request
Jan 2, 2020
This custom ESLint rule is unused since #31092. This commit removes it. PR-URL: #31147 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR
added a commit
that referenced
this pull request
Jan 3, 2020
This completely refactors the `expectsError` behavior: so far it's almost identical to `assert.throws(fn, object)` in case it was used with a function as first argument. It had a magical property check that allowed to verify a functions `type` in case `type` was passed used in the validation object. This pattern is now completely removed and `assert.throws()` should be used instead. The main intent for `common.expectsError()` is to verify error cases for callback based APIs. This is now more flexible by accepting all validation possibilites that `assert.throws()` accepts as well. No magical properties exist anymore. This reduces surprising behavior for developers who are not used to the Node.js core code base. This has the side effect that `common` is used significantly less frequent. PR-URL: #31092 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BridgeAR
pushed a commit
that referenced
this pull request
Jan 3, 2020
This custom ESLint rule is unused since #31092. This commit removes it. PR-URL: #31147 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Merged
Member
|
This needs a backport or other previous PRs to be backported in order to land on v12.x-staging. |
MylesBorins
pushed a commit
to sxa/node
that referenced
this pull request
Apr 1, 2020
This completely refactors the `expectsError` behavior: so far it's almost identical to `assert.throws(fn, object)` in case it was used with a function as first argument. It had a magical property check that allowed to verify a functions `type` in case `type` was passed used in the validation object. This pattern is now completely removed and `assert.throws()` should be used instead. The main intent for `common.expectsError()` is to verify error cases for callback based APIs. This is now more flexible by accepting all validation possibilites that `assert.throws()` accepts as well. No magical properties exist anymore. This reduces surprising behavior for developers who are not used to the Node.js core code base. This has the side effect that `common` is used significantly less frequent. Backport-PR-URL: nodejs#31449 PR-URL: nodejs#31092 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
MylesBorins
pushed a commit
that referenced
this pull request
Apr 1, 2020
This completely refactors the `expectsError` behavior: so far it's almost identical to `assert.throws(fn, object)` in case it was used with a function as first argument. It had a magical property check that allowed to verify a functions `type` in case `type` was passed used in the validation object. This pattern is now completely removed and `assert.throws()` should be used instead. The main intent for `common.expectsError()` is to verify error cases for callback based APIs. This is now more flexible by accepting all validation possibilites that `assert.throws()` accepts as well. No magical properties exist anymore. This reduces surprising behavior for developers who are not used to the Node.js core code base. This has the side effect that `common` is used significantly less frequent. Backport-PR-URL: #31449 PR-URL: #31092 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Merged
targos
pushed a commit
to targos/node
that referenced
this pull request
Apr 25, 2020
This custom ESLint rule is unused since nodejs#31092. This commit removes it. PR-URL: nodejs#31147 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
targos
pushed a commit
that referenced
this pull request
Apr 28, 2020
This custom ESLint rule is unused since #31092. This commit removes it. PR-URL: #31147 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This completely refactors the
expectsErrorbehavior: so far it'salmost identical to
assert.throws(fn, object)in case it was usedwith a function as first argument. It had a magical property check
that allowed to verify a functions
typein case thetypepropertywas set. This pattern is now completely removed and
assert.throws()should be used instead.
The main intent for
common.expectsError()is to verify error casesfor callback based APIs. This is now more flexible by accepting all
validation possibilities that
assert.throws()accepts. Nomagical properties exist anymore. This reduces surprising behavior
for developers who are not used to the Node.js core code base.
The custom
prefer-common-expectserroreslint rule comes obsolete withthis change and
commonus used significantly less frequent.Refs: #30186 (comment)
Most changes are trivial and it should be possible to skim through
most of them.
Files that have been changed more "significantly":
test/parallel/test-crypto.jstest/common/index.jstest/common/README.mdtest/parallel/test-eslint-prefer-common-expectserror.js(removed)test/parallel/test-http-invalid-path-chars.jstest/parallel/test-net-better-error-messages-port-hostname.jstest/parallel/test-net-connect-immediate-finish.jstest/parallel/test-stream-writable-change-default-encoding.jsChecklist
make -j4 test(UNIX), orvcbuild test(Windows) passes