Skip to content

Commit

Permalink
test: update mochaEvent snapshots to be auto-generated (#28224)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschile authored and cacieprins committed Nov 7, 2023
1 parent 5ef0b61 commit 1995d04
Show file tree
Hide file tree
Showing 17 changed files with 100,015 additions and 99,242 deletions.
3 changes: 3 additions & 0 deletions packages/app/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from 'cypress'
import { initGitRepoForTestProject, resetGitRepoForTestProject } from './cypress/tasks/git'
import { writeMochaEventSnapshot, readMochaEventSnapshot } from './cypress/tasks/mochaEvents'

export default defineConfig({
projectId: 'ypt4pf',
Expand Down Expand Up @@ -44,6 +45,8 @@ export default defineConfig({
on('task', {
initGitRepoForTestProject,
resetGitRepoForTestProject,
writeMochaEventSnapshot,
readMochaEventSnapshot,
})

return await e2ePluginSetup(on, config)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { loadSpec, runSpec } from './support/spec-loader'
import { runCypressInCypressMochaEventsTest } from './support/mochaEventsUtils'
import { snapshots } from './retries.experimentalRetries.mochaEvents.snapshots'

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

}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

Expand All @@ -60,7 +58,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
describe('test retry with hooks', () => {
it('matches mocha snapshot', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
`"${project}": retries mochaEvents test retry with hooks #1`,
done,
)
Expand All @@ -69,7 +66,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
fileName: 'experimental-retries/test-retry-with-hooks.retries.mochaEvents.cy.js',
projectName: project,
}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

Expand All @@ -91,7 +88,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
describe('test retry with [only]', () => {
it('matches mocha snapshot', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
`"${project}": retries mochaEvents test retry with [only] #1`,
done,
)
Expand All @@ -100,7 +96,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
fileName: 'experimental-retries/test-retry-with-only.retries.mochaEvents.cy.js',
projectName: project,
}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

Expand All @@ -122,7 +118,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
describe('can retry from [beforeEach]', () => {
it('matches mocha snapshot', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
`"${project}": retries mochaEvents can retry from [beforeEach] #1`,
done,
)
Expand All @@ -131,7 +126,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
fileName: 'experimental-retries/can-retry-from-beforeEach.retries.mochaEvents.cy.js',
projectName: project,
}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

Expand Down Expand Up @@ -247,7 +242,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
describe('can retry from [afterEach]', () => {
it('matches mocha snapshot', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
`"${project}": retries mochaEvents can retry from [afterEach] #1`,
done,
)
Expand All @@ -256,7 +250,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
fileName: 'experimental-retries/can-retry-from-afterEach.retries.mochaEvents.cy.js',
projectName: project,
}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

Expand All @@ -274,7 +268,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
describe('cant retry from [before]', () => {
it('matches mocha snapshot', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
`"${project}": retries mochaEvents cant retry from [before] #1`,
done,
)
Expand All @@ -283,7 +276,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
fileName: 'experimental-retries/cant-retry-from-before.retries.mochaEvents.cy.js',
projectName: project,
}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

Expand Down Expand Up @@ -360,7 +353,6 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
describe('three tests with retry', () => {
it('matches mocha snapshot', (done) => {
const { assertMatchingSnapshot } = runCypressInCypressMochaEventsTest(
snapshots,
`"${project}": retries mochaEvents three tests with retry #1`,
done,
)
Expand All @@ -369,7 +361,7 @@ describe('Experimental retries: mochaEvents & test status tests', { retries: 0,
fileName: 'experimental-retries/three-tests-with-retry.retries.mochaEvents.cy.js',
projectName: project,
}).then((win) => {
assertMatchingSnapshot(win)
return assertMatchingSnapshot(win)
})
})

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

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

0 comments on commit 1995d04

Please sign in to comment.