{"_id":"56954a97fe18811700c9c029","parentDoc":null,"category":{"_id":"56954a95fe18811700c9bfdf","pages":["56954a97fe18811700c9c01d","56954a97fe18811700c9c01e","56954a97fe18811700c9c01f","56954a97fe18811700c9c020","56954a97fe18811700c9c021","56954a97fe18811700c9c022","56954a97fe18811700c9c023","56954a97fe18811700c9c024","56954a97fe18811700c9c025","56954a97fe18811700c9c026","56954a97fe18811700c9c027","56954a97fe18811700c9c028","56954a97fe18811700c9c029","5696cda524490c3700170a05","5697efe61c4dc8230054268e","5697efe72cf4060d004eaa75","56993ff47465970d00650b8f","56a7a155dfdabc0d000ae910","56a7a155b5d0920d0051cd81","56a7a1a6cf6d771700baeee3","56a7a1a63d33bc2100793d5d","56a7a23097e8b00d0096d209","56a7a230ea3e3417000df4b1","56a7a25acf6d771700baeee6","56a7a25a03f28c0d00a545bf","56a7a2b83d33bc2100793d60","56a7a2b8b5d0920d0051cd82","56b27fe42db51f0d0044e566"],"project":"568fde81b700ce0d002f4b43","__v":16,"version":"56954a94fe18811700c9bfda","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-09T16:40:53.584Z","from_sync":false,"order":4,"slug":"guides","title":"Guides"},"version":{"_id":"56954a94fe18811700c9bfda","project":"568fde81b700ce0d002f4b43","__v":6,"createdAt":"2016-01-12T18:48:52.007Z","releaseDate":"2016-01-12T18:48:52.007Z","categories":["56954a95fe18811700c9bfdb","56954a95fe18811700c9bfdc","56954a95fe18811700c9bfdd","56954a95fe18811700c9bfde","56954a95fe18811700c9bfdf","56954a95fe18811700c9bfe0","56954a95fe18811700c9bfe1","56954a95fe18811700c9bfe2","56954a95fe18811700c9bfe3","56954a95fe18811700c9bfe4","5695649fdcaf0d1700cb8721","5696c1168560a60d00e2c1d6","56a7a32e79395317007c1ad6","5898fc3eec49fb0f004c2663","589cc675ea37da23004e05e1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"foo","version_clean":"0.0.0","version":"0.0"},"project":"568fde81b700ce0d002f4b43","__v":0,"user":"568fffce769f210d0013258f","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-09T18:22:25.769Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":11,"body":"# Contents\n\n- :fa-angle-right: [Mocha](#section-mocha)\n- :fa-angle-right: [Chai](#section-chai)\n- :fa-angle-right: [Chai-jQuery](#section-chai-jquery)\n- :fa-angle-right: [Sinon](#section-sinon)\n- :fa-angle-right: [Sinon-Chai](#section-sinon-chai)\n- :fa-angle-right: [Sinon-as-Promised](#section-sinon-as-romised)\n- :fa-angle-right: [Utilities](#section-utilies)\n\n***\n\n# Mocha\n\n[Mocha docs](http://mochajs.org/)\n\nCypress 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:\n\n* [describe()](https://mochajs.org/#bdd)\n* [context()](https://mochajs.org/#bdd)\n* [it()](https://mochajs.org/#bdd)\n* [before()](https://mochajs.org/#hooks)\n* [beforeEach()](https://mochajs.org/#hooks)\n* [afterEach()](https://mochajs.org/#hooks)\n* [after()](https://mochajs.org/#hooks)\n* [.only()](https://mochajs.org/#exclusive-tests)\n* [.skip()](https://mochajs.org/#inclusive-tests)\n\nAdditionally, Mocha gives us excellent [`async` support](https://mochajs.org/#asynchronous-code). Cypress has extended Mocha, sanding off the rough edges, weird edge cases, bugs, and error messages. These fixes are all completely transparent.\n\n***\n\n# Chai\n\n[Chai docs](http://chaijs.com/)\n\nWhile 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](https://on.cypress.io/guides/making-assertions) and the [cy.should](https://on.cypress.io/api/should) command.\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"[Check out our example recipe to see how to extend chai yourself](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/extending_chai_assertion_plugins_spec.js)\",\n  \"title\": \"Extending chai to use assertion plugins\"\n}\n[/block]\n\n***\n\n# Chai-jQuery\n\n[Chai-jQuery docs](https://github.com/chaijs/chai-jquery)\n\nWhen 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.\n\n***\n\n# Sinon\n\n[Sinon docs](http://sinonjs.org/)\n\nWhen writing unit tests, or even in integration-like tests, you often need to ability to [stub](http://sinonjs.org/docs/#stubs) and [spy](http://sinonjs.org/docs/#spies) methods. Cypress includes two methods, [`cy.stub`](https://on.cypress.io/api/stub) and [`cy.spy`](https://on.cypress.io/api/spy) that return Sinon stubs and spies, respectively.\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"[Check out our example recipe for stubbing dependencies in unit tests](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/unit_test_stubbing_dependencies_spec.js)\",\n  \"title\": \"Stubbing Dependencies when Unit Testing\"\n}\n[/block]\n\n***\n\n# Sinon-Chai\n\n[Sinon-Chai docs](https://github.com/domenic/sinon-chai)\n\nWhen 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](https://github.com/domenic/sinon-chai#assertions) about `stubs` and `spies`.\n\n***\n\n# Sinon-As-Promised\n\n[Sinon-As-Promised docs](https://github.com/bendrucker/sinon-as-promised)\n\nSinon-as-Promised gives you the ability to stub methods that return Promises. To fulfill the async contract of these methods, you would use Sinon-as-Promised to force these methods to easily [`resolve`](https://github.com/bendrucker/sinon-as-promised#stubresolvesvalue---stub) or [`reject`](https://github.com/bendrucker/sinon-as-promised#stubrejectserr---stub) at your discretion.\n\n***\n\n# Other Library Utilities\n\nCypress also bundles the following tools on the `Cypress` object. These can be used anywhere inside of your tests.\n\n- [Cypress._](https://on.cypress.io/api/cypress-underscore) (Underscore)\n- [Cypress.$](https://on.cypress.io/api/cypress-jquery) (jQuery)\n- [Cypress.minimatch](https://on.cypress.io/api/cypress-minimatch) (minimatch.js)\n- [Cypress.moment](https://on.cypress.io/api/cypress-moment) (moment.js)\n- [Cypress.Blob](https://on.cypress.io/api/cypress-blob) (blob utils)\n- [Cypress.Promise](https://on.cypress.io/api/cypress-promise) (Bluebird)","excerpt":"Cypress bundles together a familiar set of tools and builds heavily on them.","slug":"bundled-tools","type":"basic","title":"Bundled Tools"}

Bundled Tools

Cypress bundles together a familiar set of tools and builds heavily on them.

# Contents - :fa-angle-right: [Mocha](#section-mocha) - :fa-angle-right: [Chai](#section-chai) - :fa-angle-right: [Chai-jQuery](#section-chai-jquery) - :fa-angle-right: [Sinon](#section-sinon) - :fa-angle-right: [Sinon-Chai](#section-sinon-chai) - :fa-angle-right: [Sinon-as-Promised](#section-sinon-as-romised) - :fa-angle-right: [Utilities](#section-utilies) *** # Mocha [Mocha docs](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: * [describe()](https://mochajs.org/#bdd) * [context()](https://mochajs.org/#bdd) * [it()](https://mochajs.org/#bdd) * [before()](https://mochajs.org/#hooks) * [beforeEach()](https://mochajs.org/#hooks) * [afterEach()](https://mochajs.org/#hooks) * [after()](https://mochajs.org/#hooks) * [.only()](https://mochajs.org/#exclusive-tests) * [.skip()](https://mochajs.org/#inclusive-tests) Additionally, Mocha gives us excellent [`async` support](https://mochajs.org/#asynchronous-code). Cypress has extended Mocha, sanding off the rough edges, weird edge cases, bugs, and error messages. These fixes are all completely transparent. *** # Chai [Chai docs](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](https://on.cypress.io/guides/making-assertions) and the [cy.should](https://on.cypress.io/api/should) command. [block:callout] { "type": "info", "body": "[Check out our example recipe to see how to extend chai yourself](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/extending_chai_assertion_plugins_spec.js)", "title": "Extending chai to use assertion plugins" } [/block] *** # Chai-jQuery [Chai-jQuery docs](https://github.com/chaijs/chai-jquery) When 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 [Sinon docs](http://sinonjs.org/) When writing unit tests, or even in integration-like tests, you often need to ability to [stub](http://sinonjs.org/docs/#stubs) and [spy](http://sinonjs.org/docs/#spies) methods. Cypress includes two methods, [`cy.stub`](https://on.cypress.io/api/stub) and [`cy.spy`](https://on.cypress.io/api/spy) that return Sinon stubs and spies, respectively. [block:callout] { "type": "info", "body": "[Check out our example recipe for stubbing dependencies in unit tests](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/unit_test_stubbing_dependencies_spec.js)", "title": "Stubbing Dependencies when Unit Testing" } [/block] *** # Sinon-Chai [Sinon-Chai docs](https://github.com/domenic/sinon-chai) When 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](https://github.com/domenic/sinon-chai#assertions) about `stubs` and `spies`. *** # Sinon-As-Promised [Sinon-As-Promised docs](https://github.com/bendrucker/sinon-as-promised) Sinon-as-Promised gives you the ability to stub methods that return Promises. To fulfill the async contract of these methods, you would use Sinon-as-Promised to force these methods to easily [`resolve`](https://github.com/bendrucker/sinon-as-promised#stubresolvesvalue---stub) or [`reject`](https://github.com/bendrucker/sinon-as-promised#stubrejectserr---stub) at your discretion. *** # Other Library Utilities Cypress also bundles the following tools on the `Cypress` object. These can be used anywhere inside of your tests. - [Cypress._](https://on.cypress.io/api/cypress-underscore) (Underscore) - [Cypress.$](https://on.cypress.io/api/cypress-jquery) (jQuery) - [Cypress.minimatch](https://on.cypress.io/api/cypress-minimatch) (minimatch.js) - [Cypress.moment](https://on.cypress.io/api/cypress-moment) (moment.js) - [Cypress.Blob](https://on.cypress.io/api/cypress-blob) (blob utils) - [Cypress.Promise](https://on.cypress.io/api/cypress-promise) (Bluebird)