Skip to content

Commit 8e3a7b5

Browse files
authored
chore: Upgrade Cypress from v9 to v12 (#37810)
1 parent 6ad3960 commit 8e3a7b5

File tree

145 files changed

+604
-604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+604
-604
lines changed

.circleci/config.yml

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,8 @@ jobs:
315315

316316
e2e_tests_path-prefix:
317317
<<: *e2e-executor
318-
environment:
319-
<<: *e2e-executor-env
320-
CYPRESS_PROJECT_ID: pzj19c
321-
CYPRESS_RECORD_KEY: c9ea1b91-eed6-4bac-be41-eccd75a48969
322318
steps:
319+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_PATH_PREFIX}"' >> "$BASH_ENV"
323320
- e2e-test:
324321
test_path: e2e-tests/path-prefix
325322

@@ -375,75 +372,60 @@ jobs:
375372

376373
e2e_tests_development_runtime_with_react_18:
377374
<<: *e2e-executor
378-
environment:
379-
<<: *e2e-executor-env
380-
CYPRESS_PROJECT_ID: nusozx
381-
CYPRESS_RECORD_KEY: 6500fa9b-7710-4968-b321-1a544c9a1fdc
382375
steps:
376+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_DEV_RUNTIME_REACT_18}"' >> "$BASH_ENV"
383377
- e2e-test:
384378
test_path: e2e-tests/development-runtime
385379

386380
e2e_tests_production_runtime_with_react_18:
387381
<<: *e2e-executor
388382
steps:
383+
- run: echo 'export CY_CLOUD_PROD_RUNTIME_OFFLINE_REACT_18="${CY_CLOUD_PROD_RUNTIME_OFFLINE_REACT_18}"' >> "$BASH_ENV"
384+
- run: echo 'export CY_CLOUD_PROD_RUNTIME_REACT_18="${CY_CLOUD_PROD_RUNTIME_REACT_18}"' >> "$BASH_ENV"
389385
- e2e-test:
390386
test_path: e2e-tests/production-runtime
391-
test_command: CYPRESS_PROJECT_ID=5k8zbj CYPRESS_RECORD_KEY=ec36ff6b-3db9-48a9-8f7b-2faf301ab800 yarn test && CYPRESS_PROJECT_ID=yvdct2 CYPRESS_RECORD_KEY=2a4f4f31-0dfb-4a56-80e0-9ed42a1131a4 yarn test:offline
387+
test_command: CYPRESS_PROJECT_ID=5k8zbj CYPRESS_RECORD_KEY=${CY_CLOUD_PROD_RUNTIME_REACT_18} yarn test && CYPRESS_PROJECT_ID=yvdct2 CYPRESS_RECORD_KEY=${CY_CLOUD_PROD_RUNTIME_OFFLINE_REACT_18} yarn test:offline
392388

393389
themes_e2e_tests_development_runtime:
394390
<<: *e2e-executor
395-
environment:
396-
<<: *e2e-executor-env
397-
CYPRESS_PROJECT_ID: 9parq5
398-
CYPRESS_RECORD_KEY: 3fb49000-4143-4bd8-9ab4-219389060910
399391
steps:
392+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_THEMES_DEV_RUNTIME}"' >> "$BASH_ENV"
400393
- e2e-test:
401394
test_path: e2e-tests/themes
402395
test_command: cd development-runtime; yarn test
403396

404397
themes_e2e_tests_production_runtime:
405398
<<: *e2e-executor
406-
environment:
407-
<<: *e2e-executor-env
408-
CYPRESS_PROJECT_ID: c9rs27
409-
CYPRESS_RECORD_KEY: e4e7b3b8-e1e7-4a74-a0c9-9ac76585236b
410399
steps:
400+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_THEMES_PROD_RUNTIME}"' >> "$BASH_ENV"
411401
- e2e-test:
412402
test_path: e2e-tests/themes
413403
test_command: cd production-runtime; yarn test
414404

415405
e2e_tests_mdx:
416406
<<: *e2e-executor
417407
steps:
408+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_MDX}"' >> "$BASH_ENV"
418409
- e2e-test:
419410
test_path: e2e-tests/mdx
420-
test_command: CYPRESS_PROJECT_ID=spbj28 CYPRESS_RECORD_KEY=af30ea46-121f-4fb7-97dd-f17ec224402e yarn test
421411

422412
e2e_tests_visual-regression:
423413
<<: *e2e-executor
424-
environment:
425-
<<: *e2e-executor-env
426-
CYPRESS_PROJECT_ID: nz99aw
427-
CYPRESS_RECORD_KEY: ed4b1af1-bd97-47d4-bb09-3cab2435a147
428414
steps:
415+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_VISUAL_REGRESSION}"' >> "$BASH_ENV"
429416
- e2e-test:
430417
test_path: e2e-tests/visual-regression
431-
test_command: yarn test
432418
- store_artifacts:
433419
path: e2e-tests/visual-regression/__diff_output__
434420
- store_test_results:
435421
path: e2e-tests/visual-regression/cypress/results
436422

437423
e2e_tests_contentful:
438424
<<: *e2e-executor
439-
environment:
440-
<<: *e2e-executor-env
441-
CYPRESS_PROJECT_ID: 2193cm
442-
CYPRESS_RECORD_KEY: 57e9563e-af49-494c-837c-5af53c2d6f76
443425
steps:
426+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_CONTENTFUL}"' >> "$BASH_ENV"
444427
- e2e-test:
445428
test_path: e2e-tests/contentful
446-
test_command: yarn test
447429
# we build a second time to see if warm/cached builds are successful
448430
- e2e-test:
449431
test_path: e2e-tests/contentful
@@ -455,14 +437,10 @@ jobs:
455437

456438
e2e_tests_trailing-slash:
457439
<<: *e2e-executor
458-
environment:
459-
<<: *e2e-executor-env
460-
CYPRESS_PROJECT_ID: ofxgw8
461-
CYPRESS_RECORD_KEY: 29c32742-6b85-40e0-9b45-a4c722749d52
462440
steps:
441+
- run: echo 'export CYPRESS_RECORD_KEY="${CY_CLOUD_TRAILING_SLASH}"' >> "$BASH_ENV"
463442
- e2e-test:
464443
test_path: e2e-tests/trailing-slash
465-
test_command: yarn test
466444
- store_test_results:
467445
path: e2e-tests/trailing-slash/cypress/results
468446

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { defineConfig } from "cypress"
2+
import { addMatchImageSnapshotPlugin } from "@simonsmith/cypress-image-snapshot/plugin"
3+
4+
export default defineConfig({
5+
e2e: {
6+
baseUrl: `http://localhost:9000`,
7+
specPattern: `cypress/integration/**/*.{js,ts}`,
8+
projectId: `2193cm`,
9+
viewportWidth: 1440,
10+
viewportHeight: 900,
11+
retries: {
12+
runMode: 0,
13+
openMode: 0
14+
},
15+
videoUploadOnPasses: false,
16+
setupNodeEvents(on, config) {
17+
addMatchImageSnapshotPlugin(on, config)
18+
on("before:browser:launch", (browser = {} as Cypress.Browser, launchOptions) => {
19+
if (browser.family === "chromium" || browser.name === "chrome") {
20+
// Make retina screens run at 1x density so they match the versions in CI
21+
launchOptions.args.push("--force-device-scale-factor=1")
22+
}
23+
return launchOptions
24+
})
25+
},
26+
},
27+
env: {
28+
requireSnapshots: true,
29+
}
30+
})

e2e-tests/contentful/cypress.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

e2e-tests/contentful/cypress/integration/gatsby-image-cdn.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { parseSrcset } from "srcset"
2-
31
const testConfig = {
42
retries: {
53
runMode: 2,

e2e-tests/contentful/cypress/plugins/index.js

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "gatsby-cypress"
2+
import { addMatchImageSnapshotCommand } from "@simonsmith/cypress-image-snapshot/command"
3+
import { register } from "@cypress/snapshot"
4+
5+
addMatchImageSnapshotCommand({
6+
customDiffDir: `/__diff_output__`,
7+
customDiffConfig: {
8+
threshold: 0.1,
9+
},
10+
failureThreshold: 0.08,
11+
failureThresholdType: `percent`,
12+
})
13+
14+
register()

e2e-tests/contentful/cypress/support/index.js

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["es5", "dom"],
5+
"types": ["cypress", "node"]
6+
},
7+
"include": ["**/*.ts"]
8+
}

e2e-tests/contentful/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
},
2020
"devDependencies": {
2121
"@cypress/snapshot": "^2.1.7",
22+
"@simonsmith/cypress-image-snapshot": "^6.0.1",
23+
"@types/simonsmith__cypress-image-snapshot": "npm:@types/cypress-image-snapshot",
2224
"cross-env": "^7.0.3",
23-
"cypress": "^9.7.0",
24-
"cypress-image-snapshot": "^4.0.1",
25+
"cypress": "^12.9.0",
2526
"gatsby-cypress": "next",
2627
"prettier": "^2.8.7",
2728
"srcset": "^5.0.0",
28-
"start-server-and-test": "^1.15.3"
29+
"start-server-and-test": "^2.0.0",
30+
"typescript": "^5.0.2"
2931
},
3032
"keywords": [
3133
"gatsby"
@@ -39,8 +41,8 @@
3941
"test": "cross-env CYPRESS_SUPPORT=y npm run build && npm run start-server-and-test",
4042
"start-server-and-test": "start-server-and-test serve http://localhost:9000 cy:run",
4143
"serve": "gatsby serve",
42-
"cy:open": "cypress open",
43-
"cy:run": "node ../../scripts/cypress-run-with-conditional-record-flag.js --browser chrome"
44+
"cy:open": "cypress open --browser chrome --e2e",
45+
"cy:run": "node ../../scripts/cypress-run-with-conditional-record-flag.js --browser chrome --e2e"
4446
},
4547
"repository": {
4648
"type": "git",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { defineConfig } from "cypress"
2+
import { addMatchImageSnapshotPlugin } from "@simonsmith/cypress-image-snapshot/plugin"
3+
import { gatsbyConfigUtils } from "./cypress/utils/gatsby-config"
4+
import { blockResourcesUtils } from "./cypress/utils/block-resources"
5+
6+
export default defineConfig({
7+
e2e: {
8+
baseUrl: `http://localhost:8000`,
9+
specPattern: `cypress/integration/**/*.{js,ts}`,
10+
projectId: `nusozx`,
11+
experimentalRunAllSpecs: true,
12+
chromeWebSecurity: false,
13+
defaultCommandTimeout: 30000,
14+
retries: 2,
15+
videoUploadOnPasses: false,
16+
setupNodeEvents(on, config) {
17+
addMatchImageSnapshotPlugin(on, config)
18+
on(`task`, {
19+
...blockResourcesUtils,
20+
...gatsbyConfigUtils,
21+
})
22+
on(`before:browser:launch`, (browser = {} as Cypress.Browser, launchOptions) => {
23+
if (browser.family === `chromium` || browser.name === `chrome`) {
24+
// Make retina screens run at 1x density so they match the versions in CI
25+
launchOptions.args.push(`--force-device-scale-factor=1`)
26+
}
27+
return launchOptions
28+
})
29+
},
30+
},
31+
env: {
32+
requireSnapshots: true,
33+
}
34+
})

e2e-tests/development-runtime/cypress.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

e2e-tests/development-runtime/cypress/integration/hot-reloading/error-handling/compile-error.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ const errorPlaceholder = `// compile-error`
1414
const errorReplacement = `a b`
1515

1616
describe(`testing error overlay and ability to automatically recover from webpack compile errors`, () => {
17-
it(`displays content initially (no errors yet)`, () => {
17+
beforeEach(() => {
1818
cy.visit(`/error-handling/compile-error/`).waitForRouteChange()
19+
})
20+
21+
it(`displays content initially (no errors yet)`, () => {
1922
cy.findByTestId(`hot`).should(`contain.text`, `Working`)
2023
})
2124

e2e-tests/development-runtime/cypress/integration/hot-reloading/error-handling/page-query-result-runtime-error.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ after(() => {
2727
const errorPlaceholder = `false`
2828
const errorReplacement = `true`
2929

30-
describe(`testing error overlay and ability to automatically recover runtime errors cause by content changes (page queries variant)`, () => {
31-
it(`displays content initially (no errors yet)`, () => {
30+
describe(`testing error overlay and ability to automatically recover runtime errors cause by content changes (page queries variant)`, { testIsolation: false } , () => {
31+
before(() => {
3232
cy.visit(`/error-handling/page-query-result-runtime-error/`, {
3333
// Hacky way to disable "uncaught:exception" message in error message itself
3434
// See https://github.com/cypress-io/cypress/issues/254#issuecomment-292190924
3535
onBeforeLoad: win => {
3636
win.onerror = null
3737
},
3838
}).waitForRouteChange()
39+
})
40+
41+
it(`displays content initially (no errors yet)`, () => {
3942
cy.findByTestId(`hot`).should(`contain.text`, `Working`)
4043
cy.findByTestId(`results`).should(`contain.text`, `"hasError": false`)
4144
})

e2e-tests/development-runtime/cypress/integration/hot-reloading/error-handling/query-validation-error.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ after(() => {
1313
const errorPlaceholder = `# query-validation-error`
1414
const errorReplacement = `fieldThatDoesNotExistOnSiteMapType`
1515

16-
describe(`testing error overlay and ability to automatically recover from query extraction validation errors`, () => {
17-
it(`displays content initially (no errors yet)`, () => {
16+
describe(`testing error overlay and ability to automatically recover from query extraction validation errors`, { testIsolation: false }, () => {
17+
before(() => {
1818
cy.visit(`/error-handling/query-validation-error/`).waitForRouteChange()
19+
})
20+
21+
it(`displays content initially (no errors yet)`, () => {
1922
cy.findByTestId(`hot`).should(`contain.text`, `Working`)
2023
})
2124

e2e-tests/development-runtime/cypress/integration/hot-reloading/error-handling/runtime-error.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ after(() => {
2121
const errorPlaceholder = `// runtime-error`
2222
const errorReplacement = `window.a.b.c.d.e.f.g()`
2323

24-
describe(`testing error overlay and ability to automatically recover from runtime errors`, () => {
25-
it(`displays content initially (no errors yet)`, () => {
24+
describe(`testing error overlay and ability to automatically recover from runtime errors`, { testIsolation: false }, () => {
25+
before(() => {
2626
cy.visit(`/error-handling/runtime-error/`, {
2727
// Hacky way to disable "uncaught:exception" message in error message itself
2828
// See https://github.com/cypress-io/cypress/issues/254#issuecomment-292190924
2929
onBeforeLoad: win => {
3030
win.onerror = null
3131
},
3232
}).waitForRouteChange()
33+
})
34+
35+
it(`displays content initially (no errors yet)`, () => {
3336
cy.findByTestId(`hot`).should(`contain.text`, `Working`)
3437
})
3538

0 commit comments

Comments
 (0)