-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby): expose full structured logs over the develop status we…
…bsocket server (#26000) * Remove unnecessary emit from server, use callback response instead * Expose full structured logs over the developstatusserver websocket * Clearer variable name * Merge conditionals into one * Add e2e test for restarting prompt * Increase timeout for restarting screen to be shown * Temporarily disable flakey e2e test
- Loading branch information
Showing
7 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"baseUrl": "http://localhost:8000", | ||
"failOnStatusCode": false | ||
"failOnStatusCode": false, | ||
"chromeWebSecurity": false | ||
} |
28 changes: 28 additions & 0 deletions
28
e2e-tests/development-runtime/cypress/integration/functionality/restarting-prompt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// NOTE(@mxstbr): while this e2e test runs and passes locally, it makes all other tests flakey for reasons I haven't been able to figure out | ||
describe.skip(`gatsby-config.js`, () => { | ||
beforeEach(() => { | ||
cy.visit(`/`).waitForRouteChange() | ||
}) | ||
|
||
afterEach(async () => { | ||
cy.task(`resetGatsbyConfig`) | ||
}) | ||
|
||
it(`prompts to restart when changed`, () => { | ||
cy.on(`window:confirm`, str => { | ||
expect(str).to.contain(`gatsby-config.js`) | ||
|
||
// Press "Restart" | ||
return true | ||
}) | ||
|
||
cy.task(`changeGatsbyConfig`) | ||
cy.get(`[data-cy="restarting-screen"]`, { timeout: 10000 }).should( | ||
`be.visible` | ||
) | ||
// Restarting gatsby develop can take a while | ||
cy.get(`[data-testid="page-component"]`, { timeout: 30000 }).should( | ||
`be.visible` | ||
) | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
e2e-tests/development-runtime/cypress/plugins/gatsby-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require(`fs`) | ||
const path = require(`path`) | ||
|
||
const CONFIG_PATH = path.join(__dirname, `../../gatsby-config.js`) | ||
const originalConfig = fs.readFileSync(CONFIG_PATH, `utf8`) | ||
|
||
module.exports = { | ||
resetGatsbyConfig: () => { | ||
fs.writeFileSync(CONFIG_PATH, originalConfig) | ||
return originalConfig | ||
}, | ||
changeGatsbyConfig: () => { | ||
if (fs.readFileSync(CONFIG_PATH, `utf8`) !== originalConfig) | ||
throw new Error( | ||
`It looks like the gatsby-config.js has already been changed. Please call cy.task('resetGatsbyConfig') first.` | ||
) | ||
// Switch the order of two plugins around to trigger a restart | ||
// that doesn't affect the functionality of the site. | ||
const changed = originalConfig.replace( | ||
`\`gatsby-source-fake-data\`, | ||
\`gatsby-transformer-sharp\`, | ||
`, | ||
` | ||
\`gatsby-transformer-sharp\`, | ||
\`gatsby-source-fake-data\`,` | ||
) | ||
|
||
fs.writeFileSync(CONFIG_PATH, changed) | ||
return changed | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters