Released 02/05/2017
Overview:
- We have officially implemented our Sinon.JS
integration: adding
cy.stub()
,cy.spy()
,cy.clock()
, andcy.tick()
. We've matched Sinon's APIs and addedsinon-as-promised
andchai-sinon
. In addition we've fixed Sinon performance issues, and improved the display of assertion passes and failures. - These new APIs will work well in both
unit
tests andintegration
tests.
Features:
- You can now use
cy.stub()
andcy.spy()
synchronously. These both match the Sinon API identically. We will displaystub/spy
calls in the Command Log and provide the call count, arguments, context, and return values when you click on the log. Stubs are automatically reset between tests. Fixes #377. - We've added our own special aliasing flavor to
cy.stub()
andcy.spy()
. You can use the.as()
command and we will associate spy and stub invocations (the same way we do with XHR aliasing and route matching). - We've added
cy.clock()
andcy.tick()
which are both asynchronous methods to modify timers in your application under test. We automatically apply clock (even if you invoke it before your firstcy.visit()
) and will automatically reapply it after page load.cy.tick()
will enable you to control the amount of time you want passed in your application. This is great for controlling throttled or debounced functions. sinon-as-promised
is automatically applied under the hood which extends Sinon and provides the.resolves(...)
and.rejects(...)
APIs which makes it easy to stub promise returning functions.- We support and display multiple sub spies when using Sinon's
.withArgs(...)
function.
Misc:
- We've enhanced
chai-sinon
by improving the output during passes or failures. Fixes #31. - We've ripped out Sinon's argument serialization in favor of our own.
- We no longer send Sinon to the remote application under test. In other words,
you'll no longer see
sinon.js
being sent as a network request. - Deprecated the undocumented
cy.agents
function, but it will continue to work and will be officially removed later.