Skip to content

Commit

Permalink
Fix flaky full reload hmr tests (#40786)
Browse files Browse the repository at this point in the history
The issue seems to be that ` await check(() =>
browser.elementByCss('p').text(), 'hello world!!!')` sometimes tries to
get `.text()` from the DOM before the full reload and it times out.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
  • Loading branch information
Hannes Bornö committed Sep 22, 2022
1 parent 06682d2 commit f662f18
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/development/basic/hmr.test.ts
Expand Up @@ -793,13 +793,16 @@ describe('basic HMR', () => {
)
const newFileContent = currentFileContent.replace(
'<p>hello world</p>',
'<p>hello world!!!</p>'
'<p id="updated">hello world!!!</p>'
)
await next.patchFile(
'./pages/hmr/anonymous-page-function.js',
newFileContent
)
await check(() => browser.elementByCss('p').text(), 'hello world!!!')

expect(await browser.waitForElementByCss('#updated').text()).toBe(
'hello world!!!'
)

// CLI warning and stacktrace
expect(next.cliOutput.slice(start)).toContain(
Expand Down Expand Up @@ -834,9 +837,15 @@ describe('basic HMR', () => {
const currentFileContent = await next.readFile(
'./pages/hmr/runtime-error.js'
)
const newFileContent = currentFileContent.replace('whoops', '"whoops"')
const newFileContent = currentFileContent.replace(
'whoops',
'<p id="updated">whoops</p>'
)
await next.patchFile('./pages/hmr/runtime-error.js', newFileContent)
await check(() => browser.elementByCss('body').text(), 'whoops')

expect(await browser.waitForElementByCss('#updated').text()).toBe(
'whoops'
)

// CLI warning and stacktrace
expect(next.cliOutput.slice(start)).toContain(
Expand Down

0 comments on commit f662f18

Please sign in to comment.