|
| 1 | +## Integration Tests |
| 2 | + |
| 3 | +Debugger.html integration test are end-to-end tests that simulate a user debugging an application. |
| 4 | + |
| 5 | +The tests open two browser tabs, the debuggee and debugger, and go through the steps of debugging the debuggee. |
| 6 | + |
| 7 | +Here's one test that pauses while creating a Todo. |
| 8 | + |
| 9 | +```js |
| 10 | +debugPage("todomvc"); |
| 11 | +goToSource("js/views/todo-view"); |
| 12 | +toggleBreakpoint(33); |
| 13 | + |
| 14 | +addTodo(); |
| 15 | + |
| 16 | +stepIn(); |
| 17 | +stepOver(); |
| 18 | +stepOut(); |
| 19 | +``` |
| 20 | + |
| 21 | +#### Helpful Information |
| 22 | ++ `public/js/test/integration` - tests folder |
| 23 | ++ `public/js/test/cypress/commands` - test commands folder |
| 24 | + |
| 25 | +#### Running tests |
| 26 | ++ `npm run firefox` - launch firefox |
| 27 | ++ `cypress run` - runs tests headlessly |
| 28 | ++ `cypress open` - opens cypress app |
| 29 | + |
| 30 | +**Installing Cypress** |
| 31 | +Cypress needs to be installed before tests can be run. |
| 32 | + |
| 33 | +```bash |
| 34 | +npm install -g cypress-cli |
| 35 | +cypress install |
| 36 | +``` |
| 37 | + |
| 38 | +[More Information](https://docs.cypress.io/docs/installing-and-running) |
| 39 | + |
| 40 | +Notes: |
| 41 | ++ It's helpful to close the firefox debugger in other tabs as it might cause the tests to miss a firefox message. |
| 42 | ++ You can also test chrome by opening chrome and enabling the chrome test in `todomvc.js`. |
| 43 | + |
| 44 | +#### Cypress |
| 45 | + |
| 46 | +The Debugger.html project uses [Cypress](https://www.cypress.io/) for integration tests. |
| 47 | + |
| 48 | +**Features** |
| 49 | + |
| 50 | ++ [Commands](https://docs.cypress.io/docs/issuing-commands) that interact with the app (click, type, ...) |
| 51 | ++ [Selectors](https://docs.cypress.io/docs/finding-elements) that wait for elements to be available (get, contains) |
| 52 | + |
| 53 | +**Pro Tips** |
| 54 | ++ `it.only` - will only run that test |
| 55 | ++ `file watching` - cypress re-runs tests on file changes. |
| 56 | + |
| 57 | +#### Fixtures |
| 58 | + |
| 59 | +We use Cypress to generate the fixtures that are used in the unit tests and storybook stories. |
| 60 | + |
| 61 | +[Fixtures](../public/js/test/integration/fixtures.js) are written like other integration tests, with an extra step for saving a fixture. |
| 62 | + |
| 63 | ++ `public/js/test/integration/fixtures.js` - fixtures file |
| 64 | ++ `public/js/test/fixtures` - Fixture folder |
| 65 | + |
| 66 | +Steps: |
| 67 | ++ start the cypress server to save the fixtures - `node bin/cypress-server` |
| 68 | ++ enable the fixture tests - change `xdescribe` to `describe` in [fixtures.js](../public/js/test/integration/fixtures.js). |
| 69 | ++ run cypress - `cypress run` |
| 70 | + |
| 71 | + |
| 72 | +#### Screenshots |
| 73 | + |
| 74 | + |
0 commit comments