Commit Graph

6 Commits

Author SHA1 Message Date
James M Snell
9cbef482df test: update multiple assert tests to use node:test
PR-URL: https://github.com/nodejs/node/pull/54585
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2024-08-29 11:40:53 -07:00
Ruben Bridgewater
1ed3c54ecb
errors: update error name
This updates all Node.js errors by removing the `code` being part
of the `name` property. Instead, the name is just changed once on
instantiation, the stack is accessed to create the stack as expected
and then the `name` property is set back to it's original form.

PR-URL: https://github.com/nodejs/node/pull/26738
Fixes: https://github.com/nodejs/node/issues/26669
Fixes: https://github.com/nodejs/node/issues/20253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-23 02:55:54 +01:00
Ruben Bridgewater
eee5adfab5
assert: add default operator to assert.fail()
This makes sure `assert.fail()` contains an operator instead of being
undefined.

On top of that it also fixes the `err.generatedMessage` property.
Before, it was not always set correct.

PR-URL: https://github.com/nodejs/node/pull/22694
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-09-17 15:59:12 +02:00
Daniel Bevenius
8fb4ea9f75 test: add deprecation code to expectWarning
This commit adds a deprecation code to expectWarning and updates the
function to check the passed code against the code property on the
warning object.

Not all warnings have a deprecation code so for those that don't an
explicit code of common.noWarnCode is required. Passing this skips the
assertion of the code.

PR-URL: https://github.com/nodejs/node/pull/19474
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-26 10:29:34 +02:00
Ruben Bridgewater
a1c96f8e07
assert: improve assert.throws
This switches the assert.throws output to the one used in strict mode
if a error object is used for comparison. From now on it will show
the complete difference between two objects instead of only showing
the first failing property.

It also fixes detecting properties with a undefined value and fails
in case the thrown error does not contain the value at all.

PR-URL: https://github.com/nodejs/node/pull/19463
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25 03:10:15 +02:00
Ruben Bridgewater
70dcacd710
assert: deprecate assert.fail partially
Using `assert.fail()` with more than one argument is not intuitive
to use and has no benefit over using a message on its own.

Therefore this introduces a runtime deprecation in case it is used
in that way.

PR-URL: https://github.com/nodejs/node/pull/18418
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-02-02 19:05:22 +01:00