Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter: Assertion API #3

Open
rauschma opened this issue Jun 26, 2018 · 6 comments
Open

Chapter: Assertion API #3

rauschma opened this issue Jun 26, 2018 · 6 comments

Comments

@rauschma
Copy link
Owner

No description provided.

@ghost
Copy link

ghost commented Jul 17, 2019

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

@ghost
Copy link

ghost commented Jul 17, 2019

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

@mday64
Copy link

mday64 commented Jan 14, 2021

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.

@mday64
Copy link

mday64 commented Jan 14, 2021

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 ===.

@rauschma
Copy link
Owner Author

rauschma commented Jan 1, 2022

@mday64 Thanks for reporting this! I switched to

import * as assert from 'assert/strict';

and don’t see the issue in VS Code anymore.

@rauschma
Copy link
Owner Author

rauschma commented Jan 1, 2022

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants