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.

chai-as-promised broken by change to addMethod and addProperty

See original GitHub issue

@keithamus @lucasfcosta @domenic

A PR submitted back in March (https://github.com/chaijs/chai/pull/642) seems to break chai-as-promised. The PR changed addMethod and addProperty so that it returns a new assertion with flags transferred over instead of returning this. However, it seems that chai-as-promised relies on the previous behavior so as not to lose the promise throughout the chain.

I haven’t yet dived in deeply enough to know if this is in an easy fix (for chai or for chai-as-promised). Just raising awareness.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
domeniccommented, Jun 17, 2016

OK, great! Happy to accept fixes to Chai as Promised once Chai 4.0 is released, but it’s good to know no existing users who respect the peer dependency warnings will be broken.

1reaction
meebercommented, Jun 14, 2016

This problem can be resolved from within chai by adding chai-as-promised’s transferPromiseness logic before the return newAssertion in addMethod and addProperty:

var newAssertion = new chai.Assertion();
transferFlags(this, newAssertion);
if ("then" in this) newAssertion.then = this.then.bind(this);  // Resolves the problem
return newAssertion;

But I haven’t found a way to resolve it from within chai-as-promised.

Edit: Opened PR with possible solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

4.x.x Complete Migration Guide #781 - chaijs/chai - GitHub
This change causes the assertion to pass instead. ... chai-as-promised broken by change to addMethod and addProperty #723, PRs: addMethod ...
Read more >
Diff - infra/third_party/npm_modules - Google Git
-These changes have been implemented in a non-breaking way, but a depretiation -warning will be presented to users until they migrate.
Read more >
Chai Assertions for Promises
Chai as Promised extends Chai with a fluent language for asserting facts about ... To change this behavior, for instance to output a...
Read more >
chakram - UNPKG
node_modules/chai-as-promised/lib/chai-as-promised.js", ... This is no longer recommended, instead use either addMethod, addProperty or addRawPlugin.
Read more >
2702747-2.patch - Drupal
Instead +of using `addProperty` to register terminating assertions, ... + +These changes have been implemented in a non-breaking way, but a depretiation ...
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