Bundled Libraries
Cypress relies on many best-of-breed open source testing libraries to lend stability and familiarity to the platform from the get-go. If you've been testing in JavaScript, you'll recognize many old friends in this list. Understand how we exploit them and hit the ground running with Cypress!
Mocha​
http://mochajs.org/Cypress has adopted Mocha's bdd
syntax, which fits perfectly with both
integration and unit testing. All of the tests you'll be writing sit on the
fundamental harness Mocha provides, namely:
Additionally, Mocha gives us excellent
async
support. Cypress has extended
Mocha, sanding off the rough edges, weird edge cases, bugs, and error messages.
These fixes are all completely transparent.
Chai​
http://chaijs.com/While Mocha provides us a framework to structure our tests, Chai gives us the
ability to easily write assertions. Chai gives us readable assertions with
excellent error messages. Cypress extends this, fixes several common pitfalls,
and wraps Chai's DSL using
subjects and the
.should()
command.
Chai-jQuery​
https://github.com/chaijs/chai-jqueryWhen writing integration tests, you will likely work a lot with the DOM. Cypress brings in Chai-jQuery, which automatically extends Chai with specific jQuery chainer methods.
Sinon.js​
https://github.com/sinonjs/sinonWhen writing unit tests, or even in integration-like tests, you often need to
ability to stub and spy methods. Cypress includes two methods,
cy.stub()
and cy.spy()
that
return Sinon stubs and spies, respectively.
Cypress also exposes a utility so that sinon
can be called anywhere inside of
your tests using Cypress.sinon
.
Sinon-Chai​
https://github.com/cypress-io/sinon-chaiWhen working with stubs
or spies
you'll regularly want to use those when
writing Chai assertions. Cypress bundles in Sinon-Chai which extends Chai
allowing you to write assertions
about stubs
and spies
.
Other Library Utilities​
Cypress also bundles the following tools on the Cypress
object. These can be
used anywhere inside of your tests.
Cypress._
(lodash)Cypress.$
(jQuery)Cypress.minimatch
(minimatch.js)Cypress.Blob
(Blob utils)Cypress.Buffer
(Buffer utils)Cypress.Promise
(Bluebird)