Unverified Commit f662f181 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Fix flaky full reload hmr tests (#40786)

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)
parent 06682d27
...@@ -793,13 +793,16 @@ describe('basic HMR', () => { ...@@ -793,13 +793,16 @@ describe('basic HMR', () => {
) )
const newFileContent = currentFileContent.replace( const newFileContent = currentFileContent.replace(
'<p>hello world</p>', '<p>hello world</p>',
'<p>hello world!!!</p>' '<p id="updated">hello world!!!</p>'
) )
await next.patchFile( await next.patchFile(
'./pages/hmr/anonymous-page-function.js', './pages/hmr/anonymous-page-function.js',
newFileContent newFileContent
) )
await check(() => browser.elementByCss('p').text(), 'hello world!!!')
expect(await browser.waitForElementByCss('#updated').text()).toBe(
'hello world!!!'
)
// CLI warning and stacktrace // CLI warning and stacktrace
expect(next.cliOutput.slice(start)).toContain( expect(next.cliOutput.slice(start)).toContain(
...@@ -834,9 +837,15 @@ describe('basic HMR', () => { ...@@ -834,9 +837,15 @@ describe('basic HMR', () => {
const currentFileContent = await next.readFile( const currentFileContent = await next.readFile(
'./pages/hmr/runtime-error.js' './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 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 // CLI warning and stacktrace
expect(next.cliOutput.slice(start)).toContain( expect(next.cliOutput.slice(start)).toContain(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment