{"__v":1,"_id":"56980d8b3503e40d0061f4fa","category":{"__v":4,"_id":"56954a95fe18811700c9bfdc","pages":["56954a97fe18811700c9c01c","5697efe61c4dc8230054268d","56980d8b3503e40d0061f4fa","569813082cf4060d004eaac3"],"project":"568fde81b700ce0d002f4b43","version":"56954a94fe18811700c9bfda","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-08T17:24:53.954Z","from_sync":false,"order":1,"slug":"getting-started","title":"Getting Started"},"parentDoc":null,"project":"568fde81b700ce0d002f4b43","user":"568fffce769f210d0013258f","version":{"__v":6,"_id":"56954a94fe18811700c9bfda","project":"568fde81b700ce0d002f4b43","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"},"updates":["581da0d0440e5d0f0018dd53"],"next":{"pages":[],"description":""},"createdAt":"2016-01-14T21:05:15.363Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"# Contents\n\n- :fa-angle-right: [Folder Structure](#section-folder-structure)\n- :fa-angle-right: [Test Files](#section-test-files)\n- :fa-angle-right: [How to Write Tests](#section-how-to-write-tests)\n\n***\n\n# Folder Structure\n\nAfter adding a new project, Cypress will automatically scaffold out a suggested folder structure. By default it will create:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"/cypress\\n/cypress/fixtures\\n/cypress/integration\\n/cypress/support\\n\",\n            \"language\": \"text\"\n        }\n    ]\n}\n[/block]\n\nCypress also adds placeholder files to help get you started with examples in each folder.\n\n**Example JSON fixture**\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"/cypress/fixtures/example.json\\n\",\n            \"language\": \"text\"\n        }\n    ]\n}\n[/block]\n\n**Example Integration Test**\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"/cypress/integration/example_spec.js\\n\",\n            \"language\": \"text\"\n        }\n    ]\n}\n[/block]\n\n**Example JavaScript Support Files**\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"/cypress/support/commands.js\\n/cypress/support/defaults.js\\n/cypress/support/index.js\\n\",\n            \"language\": \"text\"\n        }\n    ]\n}\n[/block]\n\nWhile Cypress allows for configuration of where your tests, fixtures, and support files can be located, if you're starting your first project, we recommend you use the above structure.\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"You can modify the folder configuration in your `cypress.json`. See [configuration](https://on.cypress.io/guides/configuration) for more detail.\",\n  \"title\": \"Configure Folder Structure\"\n}\n[/block]\n\n***\n\n# Test Files\n\nTest files may be written as `.js`, `.jsx`, `.coffee`, or `cjsx` files.\n\nCypress supports ES2015, ES2016, ES2017, and JSX. ES2015 modules and CommonJS modules are also supported, so you can `import` or `require` both npm packages and local modules.\n\nTo see an example of every command used in Cypress, open the `example_spec.js` within your `cypress/integration` folder.\n\nTo start writing tests for your app, simply create a new file like `app_spec.js` within your `cypress/integration` folder. Refresh your tests list in the Cypress GUI and your new file should have appeared in the list.\n\n***\n\n# How to write tests\n\nCypress is built on top of [Mocha](https://on.cypress.io/guides/bundled-tools#section-mocha) and uses its `bdd` interface. Tests you write in Cypress will mostly adhere to this style.\n\nIf you're familiar with writing tests in JavaScript, then writing tests in Cypress will be a breeze.\n\nWe're still working on introductory docs and videos. For now, [check out some examples](https://on.cypress.io/guides/all-example-apps) of applications using Cypress tests.","excerpt":"Walkthrough writing your first test","slug":"writing-your-first-test","type":"basic","title":"Writing Your First Test"}

Writing Your First Test

Walkthrough writing your first test

# Contents - :fa-angle-right: [Folder Structure](#section-folder-structure) - :fa-angle-right: [Test Files](#section-test-files) - :fa-angle-right: [How to Write Tests](#section-how-to-write-tests) *** # Folder Structure After adding a new project, Cypress will automatically scaffold out a suggested folder structure. By default it will create: [block:code] { "codes": [ { "code": "/cypress\n/cypress/fixtures\n/cypress/integration\n/cypress/support\n", "language": "text" } ] } [/block] Cypress also adds placeholder files to help get you started with examples in each folder. **Example JSON fixture** [block:code] { "codes": [ { "code": "/cypress/fixtures/example.json\n", "language": "text" } ] } [/block] **Example Integration Test** [block:code] { "codes": [ { "code": "/cypress/integration/example_spec.js\n", "language": "text" } ] } [/block] **Example JavaScript Support Files** [block:code] { "codes": [ { "code": "/cypress/support/commands.js\n/cypress/support/defaults.js\n/cypress/support/index.js\n", "language": "text" } ] } [/block] While Cypress allows for configuration of where your tests, fixtures, and support files can be located, if you're starting your first project, we recommend you use the above structure. [block:callout] { "type": "info", "body": "You can modify the folder configuration in your `cypress.json`. See [configuration](https://on.cypress.io/guides/configuration) for more detail.", "title": "Configure Folder Structure" } [/block] *** # Test Files Test files may be written as `.js`, `.jsx`, `.coffee`, or `cjsx` files. Cypress supports ES2015, ES2016, ES2017, and JSX. ES2015 modules and CommonJS modules are also supported, so you can `import` or `require` both npm packages and local modules. To see an example of every command used in Cypress, open the `example_spec.js` within your `cypress/integration` folder. To start writing tests for your app, simply create a new file like `app_spec.js` within your `cypress/integration` folder. Refresh your tests list in the Cypress GUI and your new file should have appeared in the list. *** # How to write tests Cypress is built on top of [Mocha](https://on.cypress.io/guides/bundled-tools#section-mocha) and uses its `bdd` interface. Tests you write in Cypress will mostly adhere to this style. If you're familiar with writing tests in JavaScript, then writing tests in Cypress will be a breeze. We're still working on introductory docs and videos. For now, [check out some examples](https://on.cypress.io/guides/all-example-apps) of applications using Cypress tests.