Skip to content

Commit ebf08ee

Browse files
authored
chore(e2e-dev-runtime): bump @testing-library/cypress and adjust current data updates testing setup (#26500)
* chore(e2e-dev-runtime): bump @testing-library/cypress * chore(e2e-dev-runtime): scope fake-data source plugin data refreshes * force single cypress version ref: testing-library/cypress-testing-library#98
1 parent 9456b98 commit ebf08ee

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

e2e-tests/development-runtime/cypress/integration/gatsby-preview/updating.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ describe(`Gatsby Preview (Updating)`, () => {
1515
it(`displays initial data`, () => {
1616
cy.get(`li:eq(0) a`).click().waitForRouteChange()
1717

18-
cy.queryByText(`Hello World (1)`).should(`exist`)
18+
cy.findByText(`Hello World (1)`).should(`exist`)
1919

20-
cy.queryByText(`0`).should(`exist`)
20+
cy.findByText(`0`).should(`exist`)
2121
})
2222

2323
it(`updates and hot-reloads changes to content`, () => {
2424
cy.get(`li:eq(0) a`).click().waitForRouteChange()
2525

2626
update()
2727

28-
cy.queryByText(`1`).should(`exist`)
28+
cy.findByText(`1`).should(`exist`)
2929
})
3030

3131
it(`updates and hot-reloads new content`, () => {
@@ -45,13 +45,9 @@ describe(`Gatsby Preview (Updating)`, () => {
4545
cy.get(`li`).its(`length`).should(`be`, 1)
4646
})
4747

48-
/*
49-
* TODO: get this test passing in CI
50-
* https://github.com/testing-library/cypress-testing-library/issues/23
51-
*/
52-
it.skip(`can be triggered with webhook data`, () => {
48+
it(`can be triggered with webhook data`, () => {
5349
cy.exec(`npm run update:webhook`)
5450

55-
cy.queryByText(`Hello World from a Webhook (999)`).should(`exist`)
51+
cy.findByText(`Hello World from a Webhook (999)`).should(`exist`)
5652
})
5753
})

e2e-tests/development-runtime/cypress/integration/navigation/redirect.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ describe(`redirect`, () => {
5151
// this is sanity check for this group
5252
it(`make sure 404 is present`, () => {
5353
cy.visit(`/______not_existing_page`).waitForRouteChange()
54-
cy.queryByText("Preview custom 404 page").click()
55-
cy.queryByText("A custom 404 page wasn't detected", {
54+
cy.findByText("Preview custom 404 page").click()
55+
cy.findByText("A custom 404 page wasn't detected", {
5656
exact: false,
5757
}).should(`not.exist`)
58-
cy.queryByText(
58+
cy.findByText(
5959
"You just hit a route that does not exist... the sadness."
6060
).should(`exist`)
6161
})
@@ -83,11 +83,11 @@ describe(`redirect`, () => {
8383

8484
it(`make sure 404 is NOT present`, () => {
8585
cy.visit(`/______not_existing_page`).waitForRouteChange()
86-
cy.queryByText("Preview custom 404 page").click()
87-
cy.queryByText("A custom 404 page wasn't detected", {
86+
cy.findByText("Preview custom 404 page").click()
87+
cy.findByText("A custom 404 page wasn't detected", {
8888
exact: false,
8989
}).should(`exist`)
90-
cy.queryByText(
90+
cy.findByText(
9191
"You just hit a route that does not exist... the sadness.",
9292
{ exact: false }
9393
).should(`not.exist`)

e2e-tests/development-runtime/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434
"test": "npm run start-server-and-test || (npm run reset && exit 1)",
3535
"posttest": "npm run reset",
3636
"reset": "node scripts/reset.js",
37-
"reset:preview": "node plugins/gatsby-source-fake-data/reset.js && npm run update:preview",
37+
"reset:preview": "curl -X POST http://localhost:8000/__refresh",
3838
"update": "node scripts/update.js",
3939
"update:webhook": "node scripts/webhook.js",
40-
"update:preview": "curl -X POST http://localhost:8000/__refresh",
40+
"update:preview": "curl -X POST -d '{ \"fake-data-update\": true }' -H \"Content-Type: application/json\" http://localhost:8000/__refresh",
4141
"start-server-and-test": "start-server-and-test develop http://localhost:8000 cy:run",
4242
"cy:open": "cypress open",
4343
"cy:run": "(is-ci && cypress run --browser chrome --record) || cypress run --browser chrome"
4444
},
4545
"devDependencies": {
46-
"@testing-library/cypress": "^4.0.4",
46+
"@testing-library/cypress": "^6.0.0",
4747
"cross-env": "^5.2.0",
4848
"cypress": "3.4.1",
4949
"fs-extra": "^7.0.1",
@@ -56,5 +56,8 @@
5656
"repository": {
5757
"type": "git",
5858
"url": "https://github.com/gatsbyjs/gatsby"
59+
},
60+
"resolutions": {
61+
"cypress": "3.4.1"
5962
}
6063
}

e2e-tests/development-runtime/plugins/gatsby-source-fake-data/gatsby-node.js

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ exports.sourceNodes = async function sourceNodes({
2929
reporter.info(`Webhook data detected; creating nodes`)
3030
webhookBody.items.forEach(node => createNode(api.getNode(node, helpers)))
3131
} else {
32+
if (!(webhookBody && webhookBody[`fake-data-update`])) {
33+
await api.reset()
34+
}
3235
const [updated, deleted = []] = await api.sync(helpers)
3336

3437
updated.forEach(node => createNode(node))

0 commit comments

Comments
 (0)