forked from cypress-io/testing-workshop-cypress
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spec.js
59 lines (51 loc) · 1.63 KB
/
spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/// <reference types="cypress" />
it('loads', () => {
// application should be running at port 3000
cy.visit('localhost:3000')
cy.contains('h1', 'todos')
})
// remember to manually delete all items before running the test
it('adds two items', () => {
// repeat twice
// get the input field
// type text and "enter"
// assert that the new Todo item
// has been added added to the list
// cy.get(...).should('have.length', 2)
})
it('can mark an item as completed', () => {
// adds a few items
// marks the first item as completed
// confirms the first item has the expected completed class
// confirms the other items are still incomplete
})
it('can delete an item', () => {
// adds a few items
// deletes the first item
// use force: true because we don't want to hover
// confirm the deleted item is gone from the dom
// confirm the other item still exists
})
it('can add many items', () => {
const N = 5
for (let k = 0; k < N; k += 1) {
// add an item
// probably want to have a reusable function to add an item!
}
// check number of items
})
it('adds item with random text', () => {
// use a helper function with Math.random()
// or Cypress._.random() to generate unique text label
// add such item
// and make sure it is visible and does not have class "completed"
})
it('starts with zero items', () => {
// check if the list is empty initially
// find the selector for the individual TODO items
// in the list
// use cy.get(...) and it should have length of 0
// https://on.cypress.io/get
})
// what a challenge?
// test more UI at http://todomvc.com/examples/react/#/