-
Notifications
You must be signed in to change notification settings - Fork 35
Update chai to the latest version 🚀 #28
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
base: master
Are you sure you want to change the base?
Conversation
Version 4.0.2 just got published.Update to this version instead 🚀 Release Notes4.0.2 / 2017-06-05We have another bugfix release, addressing some issues for WebPack 1 users. Bug Fixes |
Version 4.1.0 just got published.Update to this version instead 🚀 Release Notes4.1.0 / 2017-07-11This release includes one new feature and a few bug fixes. New Features
Bug Fixes
Chores
CommitsThe new version differs by 16 commits.
There are 16 commits in total. See the full diff |
Version 4.1.1 just got published.Update to this version instead 🚀 Release Notes4.1.1 / 2017-08-05This release includes a few bug and documentation fixes. Bug Fixes
Docs
CommitsThe new version differs by 10 commits.
See the full diff |
Version 4.1.2 just got published.Update to this version instead 🚀 Release Notes4.1.2 / 2017-08-31This release fixes a bug when running in certain environments, and includes a few minor documentation fixes. Bug Fixes
DocsCommitsThe new version differs by 8 commits.
See the full diff |
Version 4.0.0 of chai just got published.
The version 4.0.0 is not covered by your current version range.
Without accepting this pull request your project will work just like it did before. There might be a bunch of new features, fixes and perf improvements that the maintainers worked on for you though.
I recommend you look into these changes and try to get onto the latest version of chai.
Given that you have a decent test suite, a passing build is a strong indicator that you can take advantage of these changes by merging the proposed change into your project. Otherwise this branch is a great starting point for you to work on the update.
Release Notes
4.0.0 / 2016-10-244.0.0
4.0 has been a huge undertaking by the chai community! A lot has changed to ensure Chai 4 is a stable, reliable, well documented codebase. Here are just some of the major improvements:
almost all documentation has been rewritten, with detailed instructions on how assertions work, which flags they can be combined with and the best practices for how to use them.
deep equality has been rewritten from the ground up to support ES6 types like
MapandSet, and better support existing types. It is now also much, much faster than before and allows us to bring some great improvements in upcoming releases.we have made sure the
deepflag now only ever does deep equality. Beforehand, it would sometimes also be used to test nested properties (for exampleexpect(foo).to.have.deep.property('bar.baz'). For nested assertions, please now use the.nestedflag.many assertions have become more strict, which means you get better error messages explaining where things have gone wrong. For the most part, this wont mean error messages where there weren't error messages before, but it will mean better error messages to replace the, sometimes cryptic, default
TypeErrormessages.we've added detections and helpful error messages for common mistakes and typos. The error messages will, in some cases, point you to documentation or in other cases suggest alternatives. These messages will continue to be improved in future releases, so let us know if you have any suggestions!
Breaking Changes
We no longer support Node v0.10 and v0.12 (since their LTS has ended) (PRs: #816, #901)
Instead of allowing the user to write the path of a property, now the deep flag performs a deep equality comparison when used with the
.propertyassertion.If you want the old behavior of using the dot or bracket notation to denote the property you want to assert against you can use the new
.nestedflag. (Related Issues: #745, #743, PRs: #758, #757)Please notice that the old methods which used the old behavior of the
deepflag on theassertinterface have been renamed. They all have had thedeepword changed by thenestedword. If you want to know more about this please take a look at #757.Previously,
expect(obj).not.property(name, val)would throw an Error ifobjdidn't have a property namedname. This change causes the assertion to pass instead.The
assert.propertyNotValandassert.deepPropertyNotValassertions were renamed toassert.notPropertyValandassert.notDeepPropertyVal, respectively. (Related Issues: #16, #743, #758)You can now use the
deepflag for the.includeassertion in order to perform adeepequality check to see if something is included on thetarget.Previously,
.includewas using strict equality (===) for non-negated property inclusion, butdeepequality for negated property inclusion and array inclusion.This change causes the .include assertion to always use strict equality unless the deep flag is set.
Please take a look at this comment if you want to know more about it. (Related Issues: #743, PRs: #760, #761)
Fix unstable behavior of the
NaNassertion. Now we use the suggested ES6 implementation.The new implementation is now more correct, strict and simple. While the old one threw false positives, the new implementation only checks if something is
NaN(or not if the.notflag is used) and nothing else. (Related Issues: #498, #682, #681, PRs: #508)The Typed Array types are now truncated if they're too long (in this case, if they exceed the
truncateThresholdvalue on theconfig). (Related Issues: #441, PRs: #576)The assertions:
within,above,least,below,most,increase,decreasewill throw an error if the assertion's target or arguments are not numbers. (Related Issues: #691, PRs: #692, #796)Previously,
expect(obj).not.ownProperty(name, val)would throw an Error if obj didn't have an own property (non-inherited) named name. This change causes the assertion to pass instead. (Related Issues: #795, #, PRs: #744, #810)*The
.emptyassertion will now throw when it is passed non-string primitives and functions (PRs: #763, #812)Assertion subject (
obj) changes when usingownPropertyorown.propertyand thus enables chaining. (Related Issues: #281, PRs: #641)The
.change,.increase, and.decreaseassertions changed from chainable method assertions to method assertions. They don't have any chaining behavior, and there's no generic semantic benefit to chaining them. (Related Issues: #917, PRs: #925)The
utils(second argument passed to thechai.usecallback function) no longer exports thegetPathValuefunction. If you want to use that please use thepathvalmodule, which is what chai uses internally now. (Related Issues: #457, #737, PRs: #830)(For plugin authors) Throw when calling
_superonoverwriteMethodif the method being overwritten isundefined.Currently if the method you are trying to overwrite is not defined and your new method calls
_superit will throw anError.(Related Issues: #467, PRs: #528)Before this change, calling
_superwould simply returnthis.(For plugin authors) Now
showDiffis turned on by default whenever theshowDiffflag is anything other thanfalse.This issue will mostly affect plugin creators or anyone that made extensions to the core, since this affects the
Assertion.assertmethod. (Related Issues: #574, PRs: #515)New Features
Throw when non-existent property is read. (Related Issues: #407, #766 PRs: #721, #770)
This is a potentially breaking change. Your build will fail if you have typos in your property assertions
Before
4.x.xwhen using property assertions they would not throw an error if you wrote it incorrectly.The example below, for example, would pass:
Since this implementation depends on ES6
Proxiesit will only work on platforms that support it.This property can be enabled (default) or disabled through the
config.useProxyproperty, for example:Add fix suggestions when accessing a nonexistent property in proxy mode. (Related Issues: #771, PRs: #782)
When a nonexistent property is accessed in proxy mode, Chai will compute the levenshtein distance to all possible properties in order to suggest the best fix to the user.
When non-chainable methods (including overwritten non-chainable methods) are used incorrectly an error will be thrown with a helpful error message. (PRs: #789)
Add a new configuration setting that describes which keys will be ignored when checking for non-existing properties on an assertion before throwing an error.
Since this implementation depends on ES6
Proxiesit will only work on platforms that support it. Also, if you disableconfig.useProxy, this setting will have no effect. (Related Issues: #765, PRs: #774)Add script that registers should as a side-effect. (Related Issues: #594, #693 PRs: #604)
You can also register should via a
mochaoption:mocha --require chai/should.The
changeassertion accepts a function as object. (Related Issues: #544, PRs: #607)You can also assert for a delta using the
byassertion alongside thechange,increaseanddecreaseassertions. (Related Issues: #339, PRs: #621).keysassertion can now operate onmaps andsets. (Related Issues: #632, PRs: #633, #668)Add compatibility with strict mode. (Related Issues: #578, PRs: #665)
Add
doesandbutas new no-op assertion. (Related Issues: #700, #339 PRs: #621, #701)Allow
useto be imported using new ES6 module syntax. (Related Issues: #718, PRs: #724)You can also use
requirealongside the new ES6 destructuring feature:Add ordered flag for members assertion. (Related Issues: #717, PRs: #728)
Add
.ownflag to.propertyassertion. It does the same thing as.ownPropertyand cannot be used alongisde the new.nestedflag. (Related Issues: #795, PRs: #810)Add
.deepsupport to.propertyassertion. (Related Issues: #795, PRs: #810)The
.emptyassertion will now work with ES6 collections (PRs: #763, #812, #814)Please notice that this assertion will throw an error when it is passed a
WeakMaporWeakSet.Add script that registers
shouldas a side-effect. This change allows you to registershouldvia a mocha option by using:mocha spec.js -r chai/register-shouldand also allows you to register the testing style globally. (Issues: #693, PRs: #868)Add script that registers
assertas a side-effect. This change allows you to registerassertvia a mocha option by using:mocha spec.js -r chai/register-assert(Issues: #693, PRs: #868, #872)Add script that registers
expectas a side-effect. This change allows you to registerexpectvia a mocha option by using:mocha spec.js -r chai/register-expect(Issues: #693, PRs: #868, #872)When the
lengthassertion is chained directly off of an uninvoked method, it referencesfunction's built-inlengthproperty instead of Chai'slengthassertion. This commit adds a guard to Chai methods to detect this problem and throw a helpful error message that advises the user on how to correct it. (Issues: #684, #841, PRs: #897)Allows the
lockSsfiflag to be set when creating new Assertion. This flag controls whether or not the givenssfiflag should retain its current value, even as assertions are chained off of this object. This is usually set totruewhen creating a new assertion from within another assertion. It's also temporarily set totruebefore an overwritten assertion gets called by the overwriting assertion. (Issues: #878, #904, PRs: #922)The
nestedInclude,deepNestedInclude,ownIncludeanddeepOwnIncludeassertions and there negated pairs were added to theassertinterface. (Issues: #905, PRs: #964)Bug Fixes
this. (Related Issues: #562, #684, #723, PRs: #642, #660).membersassertion. (Related Issues: #511, PRs: #702)same.membersto properly handle duplicates by treating each one as a unique member. (Related Issues: #590, PRs: #739)overwriteMethod,overwriteProperty,addChainableMethod,overwriteChainableMethodfunctions will return new assertion with flags copied over instead of this. (Related Issues: #562, #642, #791, PRs: #799)keysassertions will now consider size of sets. (Related Issues: #919, PRs: #924)Commits
The new version differs by 350 commits.
ab1fbadMerge pull request #973 from chaijs/chore-uncomment-travis-deploy545ca2fchore: uncomment travis lines6349ff4Merge pull request #972 from lucasfcosta/release-4.0.00fe98b1[email protected]30a4451Merge pull request #967 from lucasfcosta/remove-lib-bump8ba95a7Remove bump command to change lib/chai.js0825826Merge pull request #964 from zetamorph/assert-nestedInclude-ownIncludef3adfd9fix: PhantomJS 1.x incompatibility (#966)b744130Assert: made documentation more descriptive33e4403test: added custom message test to negated .nested-, .deep-, .own.include4180242test: added message argument to negated nested-, deep-, own- and deepOwnInclude40bb490assert interface: add .deepOwnInclude and notdeepOwnInclude97b6243assert interface: add .ownInclude and .notOwnInclude24d7fa3assert interface: add deepNestedInclude and notDeepNestedInclude7063b94assert interface: add nestedInclude and notNestedIncludeThere are 250 commits in total.
See the full diff
Not sure how things should work exactly?
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴