Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE. Chai v4 isn't released yet, version numbers in package.json still need updating.
I'm just going through some popular Chai plugins to see how much breakage there is when used with the upcoming Chai v4 release. It doesn't look like it breaks any of dirty-chai's functionality, but it does cause two tests to fail. I don't think these failed tests will impact end users of dirty-chai; they are specific to how assertions were being performed on actual Chai Assertion objects.
The test on line 127 fails for two reasons:
property
assertion is actually triggering the getter forchai.Assertion.prototype['neverFail']
, which is causing a__flag
property to be created directly onchai.Assertion.prototype
when setting thedefer
flag, which is in turn wreaking havoc on all future assertions. (This was happening in v3.5 too, just not with the same consequences).Assertion
object with the flags transferred over. Therefore, the secondshould
switches the context to the newAssertion
object instead of theneverFail
function, causing the assertion to fail.The test on line 129 fails because the
new chai.Assertion({})
that gets passed to theneverFail
getter viacall
is actually a proxifiedAssertion
object, which then gets double-wrapped inside another proxy inside of theaddChainableMethod
function. Therefore, whenshould
is called, it gets called twice (the second time is from within the proxy getter of the first call), and the end result is that the context is theAssertion
object instead of theneverFail
function.This PR refactors the tests slightly so that they work in both chai v3.5 and chai v4.0