-
Notifications
You must be signed in to change notification settings - Fork 2
/
should.cy.js
58 lines (47 loc) · 1.26 KB
/
should.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
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
// @ts-check
import '../../commands/should'
it('replaces the aliases value', () => {
cy.wrap(42).as('answer')
cy.wrap(20 + 22).should('equal', '@answer')
})
it('ignores unknown aliases', () => {
cy.wrap(42).as('answer')
cy.wrap('@unknown').should('equal', '@unknown')
})
it('ignores alias names that don not start with @', () => {
cy.wrap(42).as('answer')
cy.wrap('answer').should('equal', 'answer')
})
it('handles arrays and deep.equal', () => {
cy.wrap(['one', 'two']).as('numbers')
cy.wrap(['one', 'two']).should('deep.equal', '@numbers')
})
it('handles arrays and deep.equal with timer', () => {
const expected = []
cy.wrap(expected).as('numbers')
cy.wrap(['one', 'two']).should('deep.equal', '@numbers')
setTimeout(() => {
expected.push('one')
}, 1000)
setTimeout(() => {
expected.push('two')
}, 2000)
})
it('handles two arrays and deep.equal with timer', () => {
const expected = []
setTimeout(() => {
expected.push('one')
}, 1000)
setTimeout(() => {
expected.push('two')
}, 2000)
cy.wrap(expected).as('numbers')
const actual = []
setTimeout(() => {
actual.push('one')
}, 1500)
setTimeout(() => {
actual.push('two')
}, 2500)
cy.wrap(actual).should('deep.equal', '@numbers').and('have.length', 2)
})