impatient-js
impatient-js copied to clipboard
Chapter: Assertion API
assert.equal function tests equality with == instead of ===(as mentioned in book). Reference: https://nodejs.org/api/assert.html#assert_assert_notequal_actual_expected_message
Same for assert.notEqual function tests equality with != instead of !==(as mentioned in book). Reference: https://nodejs.org/api/assert.html#assert_assert_notequal_actual_expected_message
Visual Studio Code marks assert.equal() as deprecated, and styles the equal
as strikethrough.
This appears to be due to an older version of the @types/node module being used (12.6.2). Installing a newer version, like 14.14.21, seems to fix the issue. I did npm install @types/node
from within the impatient-js-code directory.
Note: The Visual Studio Code August 2020 update added the styling of deprecated methods, which makes the @types/node bug more obvious.
assert.equal function tests equality with == instead of ===(as mentioned in book).
Note that the book and code are using the strict version. They do import { strict as assert } from 'assert';
. That means that assert.equal()
is actually the same as assert.strictEqual()
. And that does appear to use ===
.
@mday64 Thanks for reporting this! I switched to
import * as assert from 'assert/strict';
and don’t see the issue in VS Code anymore.
@ghost:
Thanks! Originally the import statement was:
import { strict as assert } from 'assert';
To make things clearer, it is now:
import * as assert from 'assert/strict';
In the book: https://exploringjs.com/impatient-js/ch_assertion-api.html#assertions-in-software-development