Releases: chaijs/chai-spies
v1.1.0
What's Changed
- Update rollup to the latest version 🚀 by @Greenkeeper in #94
- Update rollup to the latest version 🚀 by @Greenkeeper in #95
- Update rollup to the latest version 🚀 by @Greenkeeper in #96
- Update rollup to the latest version 🚀 by @Greenkeeper in #98
- updated interface docs for clarity and to show the proper API by @gregdardis in #105
- Add TypeScript Setup To README by @JimLynchCodes in #111
- chore(travis): updates node versions for testing by @stalniy in #113
- chore(rollup): update rollup to the latest version by @stalniy in #112
- Fix restoring multiple spies by @stalniy in #114
- Replace Travis with GitHub actions by @sebamarynissen in #119
- Support
spy.on
with nullish prototype by @sebamarynissen in #118
New Contributors
- @Greenkeeper made their first contribution in #94
- @gregdardis made their first contribution in #105
- @JimLynchCodes made their first contribution in #111
- @sebamarynissen made their first contribution in #119
Full Changelog: 1.0.0...v1.1.0
1.0.0 / 2018-01-10
This is a major release which introduces many new featues, such as sandboxes, as well as new convenience methods and assertions.
This major release also comes with some breaking changes:
Breaking Changes
-
removed
reset
method. #35 (@stalniy)
You will need to update any callsites tospy.reset()
to instead assign a new spy to that variable or property. -
exposes original function body in
spy.toString
calls #93 (@stalniy)
If you check thespy.toString()
output in your tests, this will need to be changed to accomodate for this change.
Features
-
added spy.returns #35 (@stalniy)
Allows to create spies that return constant value -
added spy.on #61 (#38, @stalniy)
Allows to add spies on existing methods -
added posibility to replace original method when spying with
spy.on
#68 (#62, @stalniy)
chai.spy.on(array, 'push', returns => 5)
chai.spy.on(array, 'push', function() {
// custom implementation
})
-
added spy.restore #61 (#38, @stalniy)
Allows to remove spies added byspy.on
and restore original method implementation -
added support for sanboxes #61 (#38, @stalniy)
Now it's possible to create sanboxes and track/restore spies in sandbox -
added support for
nth
call checks #75 (#59, @cnexans)
Allows to check spy arguments on specified call
const spy = chai.spy()
spy(1); // first call
spy(2); // second call
spy(3); // third call
spy(i); // nth call
expect(spy).to.have.been.first.called.with(1)
expect(spy).to.have.been.second.called.with(2)
expect(spy).to.have.been.third.called.with(3)
expect(spy).on.nth(i).be.called.with(i)
Bug Fixes
- removed dead links in README #84, #80 (#79, @damianb)
- fixed formatting in README #67 (@jethrolarson)
- added MIT license to package.json #58 (@reiz)
- fixed
.with
when multiple identical arguments are passed in spy call #56 (#45, @meeber) - updated reference to github repository #42 (@robcolburn)
Documentation
0.7.1 / 2015-09-21
0.7.0 / 2015-07-24
Added .spy.reset()
method, to reset call counters back to 0
var spy = chai.spy('foo');
spy();
spy.should.have.been.called();
spy.reset();
spy.should.not.have.been.called();
Community Contributions
Code Features & Fixes
- #28 add spy.reset method and tests
By @d48 - #25 Fix travis API key for deployments
By @keithamus
0.6.0 / 2015-04-24
Added .spy.on
and .spy.object
to easily make new spies, for example:
// Returns `fs` but with readFile and readFileSync spied on
var fs = chai.spy.object(fs, ['readFile', 'readFileSync']);
// Shortcut for `fs.writeFile = chai.spy(fs.writeFile)`
chai.spy.on(fs, 'writeFile');
Added new assertions:
.called.min(n)/.at.least(n)
to assert a spy has been called a minimum of
n
many times..called.max(n)/.at.most(n)
to assert that a spy has been called at mostn
number of times.
Community Contributions
Code Features & Fixes
- #9 Add support for component
By @pgherveou - #15 Add
above
/below
/at.most
/
at.least
call count assertions.
By @brandonhorst - #20 Fix output for
.called()
By @Ryckes - #21 Add
.spy.on
and.spy.object
methods.
By @stalniy
Documentation fixes
0.5.1 / 2012-11-15
Small bugfix, fixing the output of the .called(n)
assertion error.
0.5.0 / 2012-11-14
A few new features:
- Add
.with()
and.exactly.with()
assertion for asserting what arguments
a spy was called with.
0.4.0 / 2012-10-09
0.3.0 / 2012-07-11
0.2.3 / 2012-07-09
Small bugfixes, improving the AMD wraper