Skip to content

Commit 1406e31

Browse files
committed
fix: end-to-end test complete todo app
1 parent 5dc65fb commit 1406e31

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules/
22
.DS_Store
33
npm-debug.log
4+
apps/todo-app-bundle.umd.js
5+
apps/todo-app-bundle.umd.js.map

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ Start Cypress using `$(npm bin)/cypress open` and execute the spec. You have ful
7171
* [src/index.js](src/index.js) the main file implementing `mount`
7272
* [components](components) different Hyper components for testing
7373
* [actions](actions) pure actions functions used from components and tests
74-
* [cypress/integration](cypress/integration) example spec files showing various test situations
74+
* [apps](apps) one or more complete bundled applications
75+
* [cypress/integration](cypress/integration) example spec files showing various test situations
7576
7677
See video of tests running on CI on the project's [Cypress Dashboard][cypress dashboard url]
7778
@@ -81,9 +82,11 @@ See video of tests running on CI on the project's [Cypress Dashboard][cypress da
8182
- [components without and with actions](cypress/integration/hello-world-component-spec.js)
8283
- [single TodoItem component](cypress/integration/todo-item-spec.js)
8384
- [entire TodoList component](cypress/integration/todo-list-spec.js)
85+
- [TodoMVC application E2E test](cypress/integration/todo-app-e2e.js) for [apps/todo.html](apps/todo.html)
8486
8587
## Package scripts
8688
89+
* `npm run build` bundles complete applications if you want to run tests against full applications
8790
* `npm run cy:open` starts Cypress GUI, which is great for TDD mode
8891
* `npm run cy:run` runs Cypress headlessly, testing all specs. Same command [runs on CI](.travis.yml) with additional `--record` argument to record the run and send to the [Cypress Dashboard][cypress dashboard url]
8992

cypress/integration/todo-app-e2e.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* eslint-env mocha */
2+
describe('Todo App E2E', () => {
3+
beforeEach(() => {
4+
// note this is end-to-end test for entire applicsation
5+
// instead of loading individusl components
6+
// we are just visiting a page - we assume the
7+
// application has been bundled, loaded and initialized
8+
cy.visit('apps/todo.html')
9+
})
10+
11+
it('loads Todo app', () => {
12+
cy.contains('h1', 'Todo')
13+
})
14+
15+
it('shows 2 todos', () => {
16+
cy.get('.todo').should('have.length', 2)
17+
})
18+
19+
it('toggles second todo several times', () => {
20+
cy
21+
.get('.todo')
22+
.eq(1)
23+
.click()
24+
.click()
25+
.click()
26+
.find('.toggle')
27+
.should('be.checked')
28+
})
29+
30+
it('completes first todo', () => {
31+
cy
32+
.get('.todo')
33+
.first()
34+
.click()
35+
.find('.toggle')
36+
.should('be.checked')
37+
// second item is still not checked
38+
cy
39+
.get('.todo')
40+
.eq(1)
41+
.find('.toggle')
42+
.should('not.be.checked')
43+
})
44+
})

cypress/integration/todo-app.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)