The following changes are required if you are upgrading from the previous version:
- Users:
- Migrate configuration options to new interface. (see notes)
- Plugin Developers:
- No changes required
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
There have been requests for changes and additions to the configuration mechanisms
and their impact in the Chai architecture. As such, we have decoupled the
configuration from the Assertion
constructor. This not only allows for centralized
configuration, but will allow us to shift the responsibility from the Assertion
constructor to the assert
interface in future releases.
These changes have been implemented in a non-breaking way, but a depretiation
warning will be presented to users until they migrate. The old config method will
be removed in either v1.11.0
or v2.0.0
, whichever comes first.
// change this:
chai.Assertion.includeStack = true;
chai.Assertion.showDiff = false;
// ... to this:
chai.config.includeStack = true;
chai.config.showDiff = false;
- @param {Boolean}
- @default
false
User configurable property, influences whether stack trace is included in
Assertion error message. Default of false
suppresses stack trace in the error
message.
- @param {Boolean}
- @default
true
User configurable property, influences whether or not the showDiff
flag
should be included in the thrown AssertionErrors. false
will always be false
;
true
will be true when the assertion has requested a diff be shown.
- @param {Number}
- @default
40
User configurable property, sets length threshold for actual and expected values in assertion errors. If this threshold is exceeded, the value is truncated.
Set it to zero if you want to disable truncating altogether.
chai.config.truncateThreshold = 0; // disable truncating
- #228 Deep equality check for memebers. @duncanbeevers
- #247 Proofreading. @didorellano
- #244 Fix
contain
/include
1.9.0 regression. @leider - #233 Improvements to
ssfi
forassert
interface. @refack - #251 New config option: object display threshold. @romario333
Thank you to all who took time to contribute!
- #183 Allow
undefined
for actual. (internal api) - Update Karam(+plugins)/Istanbul to most recent versions.
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required
- Plugin Developers:
- Review #219.
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
- #202 Improve error message for .throw(). @andreineculau
- #217 Chai tests can be run with
--watch
. @demands - #219 Add overwriteChainableMethod utility. @demands
- #224 Return error on throw method to chain on error properties. @vbardales
- #226 Add
has
to language chains. @duncanbeevers - #230 Support
{a:1,b:2}.should.include({a:1})
@jkroso - #231 Update Copyright notices to 2014 @duncanbeevers
- #232 Avoid error instantiation if possible on assert.throws. @laconbass
Thank you to all who took time to contribute!
- #225 Improved AMD wrapper provided by upstream
component(1)
. - #185
assert.throws()
returns thrown error for further assertions. - #237 Remove coveralls/jscoverage, include istanbul coverage report in travis test.
- Update Karma and Sauce runner versions for consistent CI results. No more karma@canary.
The following changes are required if you are upgrading from the previous version:
- Users:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
- Plugin Developers:
- No changes required
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
This is a small patch that updates the dependency tree so browserify users can install chai. (Remove conditional requires)
The following changes are required if you are upgrading from the previous version:
- Users:
- See
deep.equal
notes.
- See
- Plugin Developers:
- No changes required
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
This version of Chai focused on a overhaul to the deep equal utility. The code for this tool has been removed from the core lib and can now be found at: chai / deep-eql. As stated in previous releases, this is part of a larger initiative to provide transparency, independent testing, and coverage for some of the more complicated internal tools.
For the most part .deep.equal
will behave the same as it has. However, in order to provide a
consistent ruleset across all types being tested, the following changes have been made and might
require changes to your tests.
1. Strict equality for non-traversable nodes according to egal.
Previously: Non-traversable equal via ===
.
expect(NaN).to.deep.equal(NaN);
expect(-0).to.not.deep.equal(+0);
2. Arguments are not Arrays (and all types must be equal):
Previously: Some crazy nonsense that led to empty arrays deep equaling empty objects deep equaling dates.
expect(arguments).to.not.deep.equal([]);
expect(Array.prototype.slice.call(arguments)).to.deep.equal([]);
- #156 Empty object is eql to empty array
- #192 empty object is eql to a Date object
- #194 refactor deep-equal utility
Chai now runs the browser CI suite using Karma directed at SauceLabs. This means we get to know where our browser support stands... and we get a cool badge:
Look for the list of browsers/versions to expand over the coming releases.
- #195 karma test framework
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required.
- Plugin Developers:
- No changes required
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
Coverage reporting has always been available for core-developers but the data has never been published for our end users. In our ongoing effort to improve accountability this data will now be published via the coveralls.io service. A badge has been added to the README and the full report can be viewed online at the chai coveralls project. Furthermore, PRs will receive automated messages indicating how their PR impacts test coverage. This service is tied to TravisCI.
- #175 Add
bower.json
. (Fix ignore all)
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required.
- Plugin Developers:
- No changes required
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
Support has been added for the Bower Package Manager ([bower.io])(http://bower.io/). Though
Chai could be installed via Bower in the past, this update adds official support via the bower.json
specification file.
- #175 Add
bower.json
.
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required.
- Plugin Developers:
- Review AssertionError update notice.
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
Chai now uses chaijs/assertion-error instead an internal constructor. This will allow for further iteration/experimentation of the AssertionError constructor independant of Chai. Future plans include stack parsing for callsite support.
This update constructor has a different constructor param signature that conforms more with the standard
Error
object. If your plugin throws and AssertionError
directly you will need to update your plugin
with the new signature.
var AssertionError = require('chai').AssertionError;
/**
* previous
*
* @param {Object} options
*/
throw new AssertionError({
message: 'An assertion error occurred'
, actual: actual
, expect: expect
, startStackFunction: arguments.callee
, showStack: true
});
/**
* new
*
* @param {String} message
* @param {Object} options
* @param {Function} start stack function
*/
throw new AssertionError('An assertion error occurred', {
actual: actual
, expect: expect
, showStack: true
}, arguments.callee);
// other signatures
throw new AssertionError('An assertion error occurred');
throw new AssertionError('An assertion error occurred', null, arguments.callee);
This is the first non-developement dependency for Chai. As Chai continues to evolve we will begin adding more; the next will likely be improved type detection and deep equality. With Chai's userbase continually growing there is an higher need for accountability and documentation. External dependencies will allow us to iterate and test on features independent from our interfaces.
Note: The browser packaged version chai.js
will ALWAYS contain all dependencies needed to run Chai.
- #169 Fix deep equal comparison for Date/Regexp types. @katsgeorgeek
- #171 Add
assert.notOk()
. @Bartvds - #173 Fix
inspect
utility. @domenic
Thank you to all who took the time to contribute!
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required.
- Plugin Developers:
- No changes required.
- Core Contributors:
- Refresh
node_modules
folder for updated developement dependencies.
- Refresh
Regular Expressions are now tested as part of all deep equality assertions. In previous versions they silently passed for all scenarios. Thanks to @katsgeorgeek for the contribution.
- #161 Fix documented name for assert interface's isDefined method. @brandonpayton
- #168 Fix comparison equality of two regexps for when using deep equality. @katsgeorgeek
Thank you to all who took the time to contribute!
- Mocha has been locked at version
1.8.x
to ensuremocha-phantomjs
compatibility.
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required.
- Plugin Developers:
- No changes required.
- Core Contributors:
- Refresh
node_modules
folder for updated developement dependencies.
- Refresh
Asserts that the target is a superset of set
, or that the target and set
have the same members.
Order is not taken into account. Thanks to @NickHeiner for the contribution.
// (expect/should) full set
expect([4, 2]).to.have.members([2, 4]);
expect([5, 2]).to.not.have.members([5, 2, 1]);
// (expect/should) inclusion
expect([1, 2, 3]).to.include.members([3, 2]);
expect([1, 2, 3]).to.not.include.members([3, 2, 8]);
// (assert) full set
assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
// (assert) inclusion
assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members');
Most assert
functions have a negative version, like instanceOf()
has a corresponding notInstaceOf()
.
However include()
did not have a corresponding notInclude()
. This has been added.
assert.notInclude([ 1, 2, 3 ], 8);
assert.notInclude('foobar', 'baz');
- #140 Restore
call
/apply
methods for plugin interface. @RubenVerborgh - #148/#153 Add
members
andinclude.members
assertions. #NickHeiner
Thank you to all who took time to contribute!
- #142
assert#include
will no longer silently pass on wrong-type haystack. - #158
assert#notInclude
has been added. - Travis-CI now tests Node.js
v0.10.x
. Support forv0.6.x
has been removed.v0.8.x
is still tested as before.
The following changes are required if you are upgrading from the previous version:
- Users:
- Plugin Developers:
- No changes required.
- Core Contributors:
- Refresh
node_modules
folder for updated developement dependencies.
- Refresh
- #126: Add
eqls
alias foreql
. @RubenVerborgh - #127: Performance refactor for chainable methods. @RubenVerborgh
- #133: Assertion
.throw
support for primitives. @RubenVerborgh - #137: Assertion
.throw
support for empty messages. @timnew - #136: Fix backward negation messages when using
.above()
and.below()
. @whatthejeff
Thank you to all who took time to contribute!
- Improve type detection of
.a()
/.an()
to work in cross-browser scenarios. - #116:
.throw()
has cleaner display of errors when WebKit browsers. - #120:
.eql()
now works to compare dom nodes in browsers.
1. Component Support: Chai now included the proper configuration to be installed as a component. Component users are encouraged to consult chaijs.com for the latest version number as using the master branch does not gaurantee stability.
// relevant component.json
devDependencies: {
"chaijs/chai": "1.5.0"
}
Alternatively, bleeding-edge is available:
$ component install chaijs/chai
2. Configurable showDiff: Some test runners (such as mocha) include support for showing the diff of strings and objects when an equality error occurs. Chai has already included support for this, however some users may not prefer this display behavior. To revert to no diff display, the following configuration is available:
chai.Assertion.showDiff = false; // diff output disabled
chai.Assertion.showDiff = true; // default, diff output enabled
1. New Utility - type: The new utility .type()
is available as a better implementation of typeof
that can be used cross-browser. It handles the inconsistencies of Array, null
, and undefined
detection.
- @param {Mixed} object to detect type of
- @return {String} object type
chai.use(function (c, utils) {
// some examples
utils.type({}); // 'object'
utils.type(null); // `null'
utils.type(undefined); // `undefined`
utils.type([]); // `array`
});
1. Browser Testing: Browser testing of the ./chai.js
file is now available in the command line
via PhantomJS. make test
and Travis-CI will now also rebuild and test ./chai.js
. Consequently, all
pull requests will now be browser tested in this way.
Note: Contributors opening pull requests should still NOT include the browser build.
2. SauceLabs Testing: Early SauceLab support has been enabled with the file ./support/mocha-cloud.js
.
Those interested in trying it out should create a free Open Sauce account
and include their credentials in ./test/auth/sauce.json
.