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.

breaking change in 2.0 (null, undefined, arguments, ok, true, false, empty, exist)

See original GitHub issue

Before the 2.0 release of Chai, these assertions could be written as properties or as functions. For example:

expect(foo).to.be.true;
expect(foo).to.be.true();

expect(foo).to.be.empty;
expect(foo).to.be.empty();

expect(foo).to.exist;
expect(foo).to.exist();

expect(foo).to.be.null;
expect(foo).to.be.null();

The documentation on chaijs.com even explained that this dual-syntax was there to play nice with some IDEs and linting tools that flag the non-function syntax as an error. But in 2.0, the function syntax no longer exists. Was it removed by accident, or was there a reason for it?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
keithamuscommented, Feb 19, 2015

For more context on all of this:

  • #41 was the initial proposal to add method syntax (.to.be.true()).
  • #297 was the PR that was merged by me.
  • #302 is where the original discovery that the two styles were incompatible with each other was.
  • #306 is where we reverted the change.
  • https://github.com/chaijs/chai/releases/tag/v2.0.0 is where the release notes are, describing the reverted change
  • #321 and #326 are duplicates of this issue.
0reactions
keithamuscommented, Mar 4, 2015

I think the dust has settled on this now. I’m going to close this one, as I’m pretty sure we’re sticking with the property style of assertions. dirty-chai exists and is a perfectly suitable plugin for this - and is compatible with all other plugins.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 2.0
Null - and undefined-aware types. TypeScript has two special types, Null and Undefined, that have the values null and undefined respectively.
Read more >
Breaking Changes · microsoft/TypeScript Wiki - GitHub
In TypeScript 4.8, under strictNullChecks , the type-checker disables a type safety hole that was maintained for backwards-compatibility, where ...
Read more >
JavaScript check if variable exists (is defined/initialized)
The typeof operator will check if the variable is really undefined. ... work differently in Javascript, empty array [] and empty object {}...
Read more >
Understanding null safety - Dart programming language
Non-nullable and nullable types. Null safety eliminates that problem at the root by changing the type hierarchy. The Null type still exists, but...
Read more >
Everything you wanted to know about $null - PowerShell
You can think of NULL as an unknown or empty value. A variable is NULL until you assign a value or an object...
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