Skip to content

Commit 3b31e35

Browse files
authored
fix(gatsby-cypress): Add TS types & improve README (#37984)
1 parent af204d2 commit 3b31e35

File tree

22 files changed

+245
-284
lines changed

22 files changed

+245
-284
lines changed

docs/docs/how-to/testing/end-to-end-testing.md

Lines changed: 122 additions & 163 deletions
Large diffs are not rendered by default.

e2e-tests/development-runtime/cypress/support/e2e.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ Cypress.Commands.add(
107107
win.___navigate(pathname)
108108
})
109109

110-
// @ts-expect-error - gatsby-cypress doesn't have types
111110
return cy.waitForAPI(`onRouteUpdate`).then(() => subject)
112111
}
113112
)

e2e-tests/production-runtime/cypress/support/e2e.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ Cypress.Commands.add(
8282
win.___navigate(pathname)
8383
})
8484

85-
// @ts-expect-error - gatsby-cypress doesn't have types
8685
return cy.waitForAPI(`onRouteUpdate`).then(() => subject)
8786
}
8887
)

examples/using-cypress/cypress.config.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "cypress"
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: `http://localhost:8000`,
6+
specPattern: `cypress/e2e`
7+
}
8+
})

examples/using-cypress/cypress/e2e/accessibility.test.js renamed to examples/using-cypress/cypress/e2e/accessibility.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe("Accessibility tests", () => {
22
beforeEach(() => {
3-
cy.visit("/").get("main")
3+
cy.visit("/").waitForRouteChange().get("main")
44
cy.injectAxe()
55
})
66
it("Has no detectable accessibility violations on load", () => {
@@ -9,6 +9,7 @@ describe("Accessibility tests", () => {
99
it("Navigates to page 2 and checks for accessibility violations", () => {
1010
cy.findByText(/go to page 2/i)
1111
.click()
12+
.waitForRouteChange()
1213
.checkA11y()
1314
})
1415
it("Focuses on the footer link and asserts its attributes", () => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
describe("Smoke tests", () => {
2+
it("Visits the index page and navigates", () => {
3+
cy.visit("/").waitForRouteChange()
4+
cy.findByText(/go to page 2/i)
5+
.click()
6+
})
7+
})

examples/using-cypress/cypress/support/commands.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import "./commands"
1+
import "gatsby-cypress/commands"
22
import "cypress-axe"
33
import "@testing-library/cypress/add-commands"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"types": ["cypress", "@testing-library/cypress", "cypress-axe", "gatsby-cypress"]
4+
},
5+
"include": ["."]
6+
}

0 commit comments

Comments
 (0)