Conversation
This improves the error example output by reflecting the current state. It also makes sure the examples are up to date in general. `assert.throws` clarified the `ERR_AMBIGUOUS_ARGUMENT` error.
| assert.deepStrictEqual({ a: 1 }, { a: '1' }); | ||
| // AssertionError: { a: 1 } deepStrictEqual { a: '1' } | ||
| // because 1 !== '1' using SameValue comparison | ||
| // AssertionError: Input A expected to strictly deep-equal input B: |
There was a problem hiding this comment.
I removed the ERR_ASSERTION part in some cases because the line length would otherwise be above 80 characters.
|
I have some deviations from the the very first example or even strange issues on Windows 7 x64 (Node.js v10.0.0) concerning overall color handling and line breaks in the legend: Outputs + screenshots for 4 cases with the same code:
> require('assert').strict.deepEqual([1, 2, 3, 4, 5], [1, 2, 3, 4, '5']);
AssertionError [ERR_ASSERTION]: Input A expected to strictly deep-equal input B:
+ expected - actual ... Lines skipped
[
1,
...
4,
- 5
+ '5'
]
>
> node.10.0.0.v8-6.6.exe e:\DOC\prg\js\node\-test\test.js
assert.js:77
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: Input A expected to strictly deep-equal input B:
[32m+ expected [39m [31m- actual [39m ... Lines skipped
[
1,
...
4,
[31m- [39m 5
[32m+ [39m '5'
]
at Object.<anonymous> (e:\DOC\prg\js\node\-test\test.js:3:26)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:575:3)
> require('assert').strict.deepEqual([1, 2, 3, 4, 5], [1, 2, 3, 4, '5']);
AssertionError [ERR_ASSERTION]: Input A expected to strictly deep-equal input B:
+ expected - actual ... Lines skipped
[
1,
...
4,
- 5
+ '5'
]
>
winpty ./node.10.0.0.v8-6.6.exe e:/DOC/prg/js/node/-test/test.js
assert.js:77
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: Input A expected to strictly deep-equal input B:
[32m+ expected[39m [31m- actual[39m ... Lines skipped
[
1,
...
4,
[31m-[39m 5
[32m+[39m '5'
]
at Object.<anonymous> (e:\DOC\prg\js\node\-test\test.js:3:26)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:575:3)Should we ignore this? |
|
@vsemozhetbyt I removed the extra line break in here to make it clear to the reader that it is still the same error message. Besides that I do not see any differences concerning the line breaks. The color handling is indeed weird though and that is a separate concern from this PR. I am going to try to look into it, but I sadly do not have a Windows to debug this at the moment. |
This comment has been minimized.
This comment has been minimized.
|
@vsemozhetbyt oh, I cite: |
|
BTW, they are not colored in the doc site: https://nodejs.org/download/nightly/v11.0.0-nightly2018042595197ed2b0/docs/api/assert.html#assert_strict_mode |
vsemozhetbyt
left a comment
There was a problem hiding this comment.
With some possible nits)
doc/api/assert.md
Outdated
| assert.deepStrictEqual(weakMap1, weakMap2); | ||
| // OK, because it is impossible to compare the entries | ||
|
|
||
| // Fail because weakMap3 has a property that weakMap1 does not contain: |
There was a problem hiding this comment.
Fail -> Fails? (Ignore if this is a noun)
doc/api/assert.md
Outdated
| Throws `value` if `value` is not `undefined` or `null`. This is useful when | ||
| testing the `error` argument in callbacks. | ||
| testing the `error` argument in callbacks. The stack trace contains all frames | ||
| from the error passed to `ifError` including the potential new frames for |
There was a problem hiding this comment.
`ifError` -> `ifError()`?
doc/api/assert.md
Outdated
| testing the `error` argument in callbacks. | ||
| testing the `error` argument in callbacks. The stack trace contains all frames | ||
| from the error passed to `ifError` including the potential new frames for | ||
| `ifError` itself. See below for an example. |
There was a problem hiding this comment.
`ifError` -> `ifError()`?
doc/api/assert.md
Outdated
| assert.ok(); | ||
| // throws: | ||
| // "AssertionError: No value argument passed to `assert.ok`. | ||
| // AssertionError: No value argument passed to `assert.ok`. |
There was a problem hiding this comment.
TODO for another PR: unify parentheses in notStrictEqual above and check other cases?
Trott
left a comment
There was a problem hiding this comment.
LGTM with nits from @vsemozhetbyt addressed
|
Comments addressed. New CI https://ci.nodejs.org/job/node-test-pull-request-lite/602/ |
doc/api/assert.md
Outdated
|
|
||
| assert.ok(false, 'it\'s false'); | ||
| // throws "AssertionError: it's false" | ||
| // AssertionError: it's false" |
doc/api/assert.md
Outdated
|
|
||
| assert.ok(); | ||
| // AssertionError: No value argument passed to `assert.ok`. | ||
| // AssertionError: No value argument passed to `assert.ok()`. |
There was a problem hiding this comment.
FWIW, there's no period at the end of the error message:
> assert.ok()
AssertionError [ERR_ASSERTION]: No value argument passed to `assert.ok()`
> |
Comments addressed. I also moved an example higher up, so it is more prominent. CI https://ci.nodejs.org/job/node-test-pull-request-lite/607/ |
|
Landed in 6554301 |
This improves the error example output by reflecting the current state. It also makes sure the examples are up to date in general. `assert.throws` clarified the `ERR_AMBIGUOUS_ARGUMENT` error. PR-URL: nodejs#20313 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This improves the error example output by reflecting the current state. It also makes sure the examples are up to date in general. `assert.throws` clarified the `ERR_AMBIGUOUS_ARGUMENT` error. PR-URL: #20313 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>




This improves the error example output by reflecting the current
state. It also makes sure the examples are up to date in general.
assert.throwsclarified theERR_AMBIGUOUS_ARGUMENTerror.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes