-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
retries.mochaEvents.cy.ts
142 lines (124 loc) · 4.32 KB
/
retries.mochaEvents.cy.ts
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import { runSpec } from './support/spec-loader'
import { runCypressInCypressMochaEventsTest } from './support/mochaEventsUtils'
import { snapshots } from './retries.mochaEvents.snapshots'
/**
* The mochaEvent tests require a spec to be loaded and executed within an inner Cypress context.
* The spec must load and execute within the duration of the Cypress command timeout.
* The execution time of the inner Cypress is resource/OS dependant and can exceed the default value (4s),
* so we have increased the command timeout to allow the inner spec more time to complete and report
* its mocha event log.
*/
describe('src/cypress/runner retries mochaEvents', { retries: 0, defaultCommandTimeout: 7500 }, () => {
// NOTE: for test-retries
it('simple retry', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents simple retry #1',
done,
)
runSpec({
fileName: 'simple-fail.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('test retry with hooks', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents test retry with hooks #1',
done,
)
runSpec({
fileName: 'test-retry-with-hooks.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('test retry with hooks', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents test retry with hooks #1',
done,
)
runSpec({
fileName: 'test-retry-with-hooks.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('test retry with [only]', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents test retry with [only] #1',
done,
)
runSpec({
fileName: 'test-retry-with-only.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('can retry from [beforeEach]', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents can retry from [beforeEach] #1',
done,
)
runSpec({
fileName: 'can-retry-from-beforeEach.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('can retry from [afterEach]', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents can retry from [afterEach] #1',
done,
)
runSpec({
fileName: 'can-retry-from-afterEach.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('cant retry from [before]', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents cant retry from [before] #1',
done,
)
runSpec({
fileName: 'cant-retry-from-before.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
it('three tests with retry', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents three tests with retry #1',
done,
)
runSpec({
fileName: 'three-tests-with-retry.retries.mochaEvents.cy.js',
}).then((win) => {
assertMatchingSnapshot(win)
})
})
describe('cleanses errors before emitting', () => {
it('does not try to serialize error with err.actual as DOM node', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
'src/cypress/runner retries mochaEvents cleanses errors before emitting does not try to serialize error with err.actual as DOM node #1',
done,
)
runSpec({
fileName: 'does-not-serialize-dom-error.cy.js',
}).then((win) => {
// should not have err.actual, expected properties since the subject is a DOM element
assertMatchingSnapshot(win)
})
})
})
})