Skip to content

Commit 9f19f9a

Browse files
authored
test: update mochaEvent snapshots to be auto-generated (#28224)
1 parent 934f215 commit 9f19f9a

17 files changed

Lines changed: 100015 additions & 99242 deletions

packages/app/cypress.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from 'cypress'
22
import { initGitRepoForTestProject, resetGitRepoForTestProject } from './cypress/tasks/git'
3+
import { writeMochaEventSnapshot, readMochaEventSnapshot } from './cypress/tasks/mochaEvents'
34

45
export default defineConfig({
56
projectId: 'ypt4pf',
@@ -44,6 +45,8 @@ export default defineConfig({
4445
on('task', {
4546
initGitRepoForTestProject,
4647
resetGitRepoForTestProject,
48+
writeMochaEventSnapshot,
49+
readMochaEventSnapshot,
4750
})
4851

4952
return await e2ePluginSetup(on, config)

packages/app/cypress/e2e/runner/retries.experimentalRetries.mochaEvents.cy.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { loadSpec, runSpec } from './support/spec-loader'
22
import { runCypressInCypressMochaEventsTest } from './support/mochaEventsUtils'
3-
import { snapshots } from './retries.experimentalRetries.mochaEvents.snapshots'
43

54
/**
65
* The mochaEvent tests require a spec to be loaded and executed within an inner Cypress context.
@@ -28,7 +27,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
2827
describe('simple retry', () => {
2928
it('matches mocha snapshot', (done) => {
3029
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
31-
snapshots,
3230
`"${project}": retries mochaEvents simple retry #1`,
3331
done,
3432
)
@@ -38,7 +36,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
3836
projectName: project,
3937

4038
}).then((win) => {
41-
assertMatchingSnapshot(win)
39+
return assertMatchingSnapshot(win)
4240
})
4341
})
4442

@@ -60,7 +58,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
6058
describe('test retry with hooks', () => {
6159
it('matches mocha snapshot', (done) => {
6260
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
63-
snapshots,
6461
`"${project}": retries mochaEvents test retry with hooks #1`,
6562
done,
6663
)
@@ -69,7 +66,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
6966
fileName: 'experimental-retries/test-retry-with-hooks.retries.mochaEvents.cy.js',
7067
projectName: project,
7168
}).then((win) => {
72-
assertMatchingSnapshot(win)
69+
return assertMatchingSnapshot(win)
7370
})
7471
})
7572

@@ -91,7 +88,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
9188
describe('test retry with [only]', () => {
9289
it('matches mocha snapshot', (done) => {
9390
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
94-
snapshots,
9591
`"${project}": retries mochaEvents test retry with [only] #1`,
9692
done,
9793
)
@@ -100,7 +96,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
10096
fileName: 'experimental-retries/test-retry-with-only.retries.mochaEvents.cy.js',
10197
projectName: project,
10298
}).then((win) => {
103-
assertMatchingSnapshot(win)
99+
return assertMatchingSnapshot(win)
104100
})
105101
})
106102

@@ -122,7 +118,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
122118
describe('can retry from [beforeEach]', () => {
123119
it('matches mocha snapshot', (done) => {
124120
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
125-
snapshots,
126121
`"${project}": retries mochaEvents can retry from [beforeEach] #1`,
127122
done,
128123
)
@@ -131,7 +126,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
131126
fileName: 'experimental-retries/can-retry-from-beforeEach.retries.mochaEvents.cy.js',
132127
projectName: project,
133128
}).then((win) => {
134-
assertMatchingSnapshot(win)
129+
return assertMatchingSnapshot(win)
135130
})
136131
})
137132

@@ -247,7 +242,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
247242
describe('can retry from [afterEach]', () => {
248243
it('matches mocha snapshot', (done) => {
249244
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
250-
snapshots,
251245
`"${project}": retries mochaEvents can retry from [afterEach] #1`,
252246
done,
253247
)
@@ -256,7 +250,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
256250
fileName: 'experimental-retries/can-retry-from-afterEach.retries.mochaEvents.cy.js',
257251
projectName: project,
258252
}).then((win) => {
259-
assertMatchingSnapshot(win)
253+
return assertMatchingSnapshot(win)
260254
})
261255
})
262256

@@ -274,7 +268,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
274268
describe('cant retry from [before]', () => {
275269
it('matches mocha snapshot', (done) => {
276270
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
277-
snapshots,
278271
`"${project}": retries mochaEvents cant retry from [before] #1`,
279272
done,
280273
)
@@ -283,7 +276,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
283276
fileName: 'experimental-retries/cant-retry-from-before.retries.mochaEvents.cy.js',
284277
projectName: project,
285278
}).then((win) => {
286-
assertMatchingSnapshot(win)
279+
return assertMatchingSnapshot(win)
287280
})
288281
})
289282

@@ -360,7 +353,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
360353
describe('three tests with retry', () => {
361354
it('matches mocha snapshot', (done) => {
362355
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
363-
snapshots,
364356
`"${project}": retries mochaEvents three tests with retry #1`,
365357
done,
366358
)
@@ -369,7 +361,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
369361
fileName: 'experimental-retries/three-tests-with-retry.retries.mochaEvents.cy.js',
370362
projectName: project,
371363
}).then((win) => {
372-
assertMatchingSnapshot(win)
364+
return assertMatchingSnapshot(win)
373365
})
374366
})
375367

@@ -388,13 +380,12 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
388380
// 'detect-flake-and-pass-on-threshold': will run a total of 6 times. All attempts fail. The test fails
389381
// 'detect-flake-but-always-fail': will run a total of 10 times. All attempts fail. The test fails.
390382
// 'detect-flake-but-always-fail-stop-any-passed': will run a total of 10 times. All attempts fail. The test fails.
391-
describe('cleanses errors before emitting', () => {
383+
describe('cleanses errors before emitting', { defaultCommandTimeout: 15000 }, () => {
392384
it('does not try to serialize error with err.actual as DOM node', function (done) {
393385
// because there are more attempts for 'detect-flake-but-always-fail', the timeout needs to be increased
394386
this.timeout(20000)
395387

396388
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
397-
snapshots,
398389
`"${project}": retries mochaEvents cleanses errors before emitting does not try to serialize error with err.actual as DOM node #1`,
399390
done,
400391
)
@@ -404,7 +395,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
404395
projectName: project,
405396
}).then((win) => {
406397
// should not have err.actual, expected properties since the subject is a DOM element
407-
assertMatchingSnapshot(win)
398+
return assertMatchingSnapshot(win)
408399
})
409400
})
410401
})

0 commit comments

Comments
 (0)