-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfixture-spec.js
28 lines (28 loc) · 908 Bytes
/
fixture-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
// @ts-check
describe('TodoMVC', { tags: '@intercept' }, () => {
it('starts with N items', () => {
cy.intercept(
{
method: 'POST',
url: '/',
headers: {
'x-gql-operation-name': 'allTodos',
},
},
{
fixture: 'three.json',
},
).as('allTodos')
cy.visit('/')
cy.get('.todo').should('have.length', 3)
cy.get('.todo.completed').should('have.length', 2)
cy.get('.todo').not('.completed').should('have.length', 1)
// the above command splits the cy.get from cy.not commands
// which can run into troubles. For better retry-ability,
// we should use a single DOM query command.
// Luckily, cy.get supports jQuery selector syntax ":not"
// which we can use to filter the completed items.
// https://on.cypress.io/retry-ability
cy.get('.todo:not(.completed)').should('have.length', 1)
})
})