Releases: chaijs/chai
3.0.0 / 2015-06-04
This release contains some small breaking changes. Most people are unlikely to
notice them - but here are the breaking changes:
- Switched from "Component" builds to "Browserify" builds for Browsers. If
you're using RequireJS with Chai, you might notice a change (chai used to
be a global, now it won't be - instead you'll have torequire
it). .has.property('foo', undefined)
will now specifically test to make sure
that the value'foo'
is actually undefined - before it simply tested that
the key existed (but could have a value)..to.be.a('type')
has changed to support more types, including ES6 types
such as'promise'
,'symbol'
,'float32array'
etc, this also means using
ES6'sSymbol.toStringTag
affects the behaviour.to.be.a()
. In addition to
this, Errors have the type of'error'
.assert.ifError()
now follows Node'sassert.ifError()
behaviour - in other
words, if the first argument is truthy, it'll throw it.- ReleaseNotes.md is no longer maintained, see the Github Releases Page instead.
- History.md is no longer maintained, see the Github Commit Log instead.
Community Contributions
Code Features & Fixes
- #403
assert.ifError()
behaves like Node.js: it throws if the first argument is present.
By @cjqed - #419 assertion-error bumped to
^1.0.1
By @keithamus (special thanks to @simonzack for his work on assertion-error) - #421 replace type.js with type-detect module.
By @Charminbear - #439 Add
.matches()
as alias for.match()
.
By @thejameskyle - #451 Switch to using Browserify for the build system.
By @csnover - #452
.property('foo', undefined)
now actually checks to see ifobj.foo === undefined
(before it did not).
By @onefifth - #460 Automate release process as much as possible
By @keithamus
Documentation fixes
- #397 Improve docs for
.assert()
By @astorije - #401 Add some badges to the Readme.
By @keithamus - #424 Fix typo in docs for
.keys()
By @astorije - #429 Deprecate
.length(n)
from the docs - use.lengthOf(n)
instead.
By @valscion - #444 Change
.length(n)
examples to.lengthOf(n)
instead.
By @keithamus - #458 Remove stray character in
assert.notInclude
docs
By @BinaryMuse
2.3.0 / 2015-04-26
Added ownPropertyDescriptor
assertion:
expect('test').to.have.ownPropertyDescriptor('length');
expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
expect('test').ownPropertyDescriptor('length').to.have.keys('value');
Community Contributions
Code Features & Fixes
- #408 Add
ownPropertyDescriptor
assertion.
By @ljharb - #422 Improve ownPropertyDescriptor
tests.
By @ljharb
Documentation fixes
2.2.0 / 2015-03-26
Deep property strings can now be escaped using \\
- for example:
var deepCss = { '.link': { '[target]': 42 }};
expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42)
Community Contributions
Code Features & Fixes
Documentation fixes
- #405 Tweak documentation around
deep property escaping.
By @keithamus
2.1.2 / 2015-03-15
2.1.1 / 2015-03-04
Two minor bugfixes. No new features.
Community Contributions
Code Features & Fixes
- #385 Fix a bug (also described in
#387) wheredeep.property
would not work with single
key names. By @eldritch-fossicker - #379 Fix bug where tools which overwrite
primitive prototypes, such as Babel or core-js would fail.
By @dcneiner
Documentation fixes
2.1.0 / 2015-02-23
Small release; fixes an issue where the Chai lib was incorrectly reporting the
version number.
Adds new should.fail()
and expect.fail()
methods, which are convenience
methods to throw Assertion Errors.
Community Contributions
Code Features & Fixes
2.0.0 / 2015-02-09
Unfortunately with 1.10.0 - compatibility broke with older versions because of
the addChainableNoop
. This change has been reverted.
Any plugins using addChainableNoop
should cease to do so.
Any developers wishing for this behaviour can use dirty-chai
by @joshperry
Community Contributions
Code Features & Fixes
- #361
.keys()
now accepts Objects, extracting keys from them. By @gregglind - #359
.keys()
no longer mutates passed arrays. By @gregglind - #349 Add a new chainable keyword -
.which
. By @toastynerd - #333 Add
.change
,.increase
and.decrease
assertions. By @cmpolis - #335
chai.util
is now exposed @DingoEatingFuzz - #328 Add
.includes
and.contains
aliases (for.include
and.contain
). By @lo1tuma - #313 Add
.any.keys()
and.all.keys()
qualifiers. By @cjqed - #312 Add
assert.sameDeepMembers()
. By @cjqed - #311 Add
assert.isAbove()
andassert.isBelow()
. By @cjqed - #308
property
anddeep.property
now pass if a value is set toundefined
. By @prodatakey - #309 optimize deep equal in Arrays. By @ericdouglas
- #306 revert #297 - allowing lint-friendly tests. By @keithamus
Documentation fixes
- #357 Copyright year updated in docs. By @danilovaz
- #325 Fix documentation for overwriteChainableMethod. By @chasenlehara
- #334 Typo fix. By @hurrymaplelad
- #317 Typo fix. By @jasonkarns
- #318 Typo fix. By @jasonkarns
- #316 Typo fix. By @jasonkarns
1.10.0 / 2014-11-10
The following changes are required if you are upgrading from the previous version:
- Users:
- No changes required
- Plugin Developers:
- Review
addChainableNoop
notes below.
- Review
- Core Contributors:
- Refresh
node_modules
folder for updated dependencies.
- Refresh
Noop Function for Terminating Assertion Properties
The following assertions can now also be used in the function-call form:
- ok
- true
- false
- null
- undefined
- exist
- empty
- arguments
- Arguments
The above list of assertions are property getters that assert immediately on access. Because of that, they were written to be used by terminating the assertion chain with a property access.
expect(true).to.be.true;
foo.should.be.ok;
This syntax is definitely aesthetically pleasing but, if you are linting your test code, your linter will complain with an error something like "Expected an assignment or function call and instead saw an expression." Since the linter doesn't know about the property getter it assumes this line has no side-effects, and throws a warning in case you made a mistake.
Squelching these errors is not a good solution as test code is getting to be just as important as, if not more than, production code. Catching syntactical errors in tests using static analysis is a great tool to help make sure that your tests are well-defined and free of typos.
A better option was to provide a function-call form for these assertions so that the code's intent is more clear and the linters stop complaining about something looking off. This form is added in addition to the existing property access form and does not impact existing test code.
expect(true).to.be.true();
foo.should.be.ok();
These forms can also be mixed in any way, these are all functionally identical:
expect(true).to.be.true.and.not.false();
expect(true).to.be.true().and.not.false;
expect(true).to.be.true.and.not.false;
Plugin Authors
If you would like to provide this function-call form for your terminating assertion properties, there is a new function to register these types of asserts. Instead of using addProperty
to register terminating assertions, simply use addChainableNoop
instead; the arguments to both are identical. The latter will make the assertion available in both the attribute and function-call forms and should have no impact on existing users of your plugin.
Community Contributions
- #297 Allow writing lint-friendly tests. @joshperry
- #298 Add check for logging
-0
. @dasilvacontin - #300 Fix #299: the test is defining global variables @julienw
Thank you to all who took time to contribute!
1.9.2 / 2014-09-29
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
Community Contributions
- #264 Show diff for keys assertions @cjthompson
- #267 Use SVG badges @shinnn
- #268 Allow messages to be functions (sinon-compat) @charlierudolph
- #269 Remove unused argument for #lengthOf @charlierudolph
- #275 Rewrite pretty-printing HTML elements to prevent throwing internal errors @DrRataplan
- #277 Fix assert documentation for #sameMembers @charlierudolph
- #279 closeTo should check value's type before assertion @mohayonao
- #289 satisfy is called twice @charlierudolph
- #292 resolve conflicts with node-webkit and global usage @boneskull
Thank you to all who took time to contribute!
1.9.1 / 2014-03-19
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
Configuration
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.
Quick Migration
// change this:
chai.Assertion.includeStack = true;
chai.Assertion.showDiff = false;
// ... to this:
chai.config.includeStack = true;
chai.config.showDiff = false;
All Config Options
config.includeStack
User configurable property, influences whether stack trace is included in
Assertion error message. Default of false
suppresses stack trace in the error
message.
config.showDiff
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.
config.truncateThreshold (NEW)
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
Community Contributions
- #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!
Other Bug Fixes
- #183 Allow
undefined
for actual. (internal api) - Update Karam(+plugins)/Istanbul to most recent versions.