Skip to content

Commit

Permalink
test(ssr): Fix flakes (#34443)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyhopp committed Jan 11, 2022
1 parent 08c998b commit 49e0710
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion integration-tests/ssr/__tests__/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe(`SSR`, () => {
expect(String(childProcess.stdout)).toContain(
`testing these paths for differences between dev & prod outputs`
)
}, 15000)
}, 30000)

test(`it generates an error page correctly`, async () => {
const src = path.join(__dirname, `/fixtures/bad-page.js`)
Expand Down
14 changes: 11 additions & 3 deletions integration-tests/ssr/test-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ async function run() {
// Fetch once to trigger re-compilation.
await fetch(`${devSiteBasePath}/${path}`)

// Then wait for 6 seconds to ensure it's ready to go.
// Then wait for a second to ensure it's ready to go.
// Otherwise, tests are flaky depending on the speed of the testing machine.
await new Promise(resolve => {
setTimeout(() => resolve(), 6000)
setTimeout(() => resolve(), 1000)
})

let devStatus = 200
Expand Down Expand Up @@ -103,7 +103,15 @@ async function run() {
paths
)

const results = await Promise.all(paths.map(p => comparePath(p)))
const results = []

// Run comparisons serially, otherwise recompilation fetches
// interfere with each other when run within Promise.all
for (const path of paths) {
const result = await comparePath(path)
results.push(result)
}

// Test all true
if (results.every(r => r)) {
process.exit(0)
Expand Down

0 comments on commit 49e0710

Please sign in to comment.