-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathspec.cy.js
33 lines (29 loc) · 1015 Bytes
/
spec.cy.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
/// <reference types="cypress" />
// @ts-check
import '../../src'
it('finds the li elements', () => {
cy.visit('cypress/index.html')
// if the list exists, it should have three items
cy.get('#fruits li').if().should('have.length', 3)
// if the list exists, it should have three items
cy.get('#veggies li').if().should('have.length', 3)
// if the button exists, it should have certain text
// and then we click on it
cy.get('button#load').if().should('have.text', 'Load').click()
// if the button exists, click on it
cy.get('button#does-not-exist').if().click()
})
it('clicks on the button if it is visible', () => {
cy.visit('cypress/index.html')
cy.get('button#hidden').if('visible').click()
// but we can click on the visible button
cy.get('button#load').if('visible').click()
})
it('works if nothing is attached', () => {
cy.wrap(1).if('equal', 1)
cy.wrap(1)
.if('not.equal', 1)
.then((/** @type number */ subject) => {
expect(subject).to.not.equal(1)
})
})