Uh oh!
There was an error while loading. Please reload this page.
assert: combine user and generated message - #22695
Conversation
Trott
commented
Sep 5, 2018
Seems like the documentation changes could benefit from a bit of editing. @nodejs/documentation |
Trott
commented
Sep 5, 2018
What about instances where |
| Type: Runtime | ||
| Instead of accessing the generatedMessage property of `AssertionErrors`, please |
There was a problem hiding this comment.
generatedMessage -> `generatedMessage`
| Type: Runtime | ||
| Instead of accessing the generatedMessage property of `AssertionErrors`, please | ||
| check for `AssertionError#userMessage` existence instead. It contains the actual |
There was a problem hiding this comment.
Is double "Instead of... instead." OK in this sentence?
| auto-generated (`true`) or not. | ||
| * `operator` {string} Set to the passed in operator value. | ||
| * `userMessage` {any} Contains the actual passed through message by the user. | ||
| It will not be set in case the user does not provide a error message. |
BridgeAR
commented
Sep 5, 2018
The |
BridgeAR
commented
Sep 5, 2018
CITGM https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1533/
|
BridgeAR
commented
Sep 5, 2018
PTAL This PR makes all the "remove third argument in assert calls" obsolete. Refs: #22718 |
BridgeAR
commented
Sep 6, 2018
I opened a PR to fix the fastify issues. Refs: fastify/fastify#1142 |
Trott
commented
Sep 6, 2018
Might be worth pinging some mocha people (@boneskull) and code/lab people (@cjihrig, @geek) to see if this is likely to have any impact on users of their libraries. (I'm guessing not, but let's be cautious anyway.) |
mcollina
left a comment
There was a problem hiding this comment.
I don’t understand why this PR would cause such a breakage. That seems a very common pattern, and not something that would be specific to Fastify. I suspect this might be breaking more.
BridgeAR
commented
Sep 6, 2018
@fhinkel all semver major PRs need review by the TSC. Thus, I added the request for review. @mcollina this is indeed not specific to fastify, even tough I am pretty happy to see that CITGM did not find anything else. It is almost only an issue for the following case:
I am going to split this into smaller steps to (a) make the I am also going to check the usage with Gzemnid even tough most entries will likely be false positives and filtering them is not that easy / requires a lot of manual work. Adding the |
cjihrig
commented
Sep 6, 2018
This won't impact code or lab. Thank you for checking though! |
So far it was difficult to tell what the actual error was about if there was only the user error. To overcome this, the user message and the auto-generated message will now be visible at the same time.
8f9d266 to
89a9f00CompareTrott
commented
Nov 28, 2018
BridgeAR
commented
Dec 19, 2018
Closing for now. I'll open a new PR when I get to it. |
boneskull
commented
Dec 22, 2018
user installs of Mocha are not impacted directly by changes to |
There are lots of PRs that remove the message property assert calls. That message is actually pretty valuable and should not be removed. However, the message alone is often not that useful. In context with the auto-generated message it can be very valuable.
From now on it would also be possible to provide the actual input value to functions and similar instead of having to reconstruct what value the assertion failed upon:
Before, all values were coerced to a string and passing through a message would have resulted in
[object Object]as output. Now the value is inspected and fully visible.There is only one values that is not accepted as input: instances of Error (those are special handled in the way that that concrete error would be thrown in case of an failed assertion. Therefore even if someone does not anticipates this case, it's always a good assertion output). I have a follow-up PR to add support for undefined as well.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes