question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow notStrictEqual for BDD style tests (expect)

See original GitHub issue

From the documentation it doesn’t seem like the following behaviour:

assert.notStrictEqual(3, '3', 'no coercion for strict equality');

is available for bdd style tests.

The only equality tests in the “expect” part of the library is this:

expect(3).to.equal('3');

but that will fail because it uses === for the comparison.

Is there any way to get the same behaviour as notStrictEqual for expect?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
shvaikaleshcommented, Jan 11, 2017

Hey @wearhere.

If you want to avoid casting string subclass to primitive on every assertion, I believe may want to write a plugin that adds a getter like .loose that sets a flag on an assertion, and overwrite equal method to respect that flag. Something like:

expect('hi').to.loose.equal(new String('hi'))
3reactions
mansonacommented, Dec 13, 2017

@nadrane why not contribute it as a PR to chai?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assertion Styles - Chai
Assertion Styles. This section of the guide introduces you to the three different assertion styles that you may use in your testing environment....
Read more >
Automated testing with Mocha - آموزش جاوااسکریپت مدرن
Let's start with a technique named Behavior Driven Development or, in short, BDD. BDD is three things in one: tests AND documentation AND...
Read more >
Assertions | Cypress Documentation
BDD Assertions. These chainers are available for BDD assertions ( expect / should ). Aliases listed can be used interchangeably with their original...
Read more >
Chapter 9. Testing Node applications
The tests also give you confidence that your recent changes haven't introduced ... Although it defaults to a BDD style, you can also...
Read more >
Unit Testing in JavaScript
Let's test some JavaScript. We'll see two frameworks: QUnit and Mocha. ... notStrictEqual(actual, expected, message) passes if actual !== expected; assert.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found