Unverified Commit e0858ec6 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Fix flakiness of `should not cause error when removing loading.js` test (#67978)

parent f4a8008c
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, check, waitFor } from 'next-test-utils' import { assertNoRedbox, retry } from 'next-test-utils'
describe('app dir', () => { describe('app dir', () => {
const { next, isNextDev, isNextStart, skipped } = nextTestSetup({ const { next, isNextDev, isNextStart, skipped } = nextTestSetup({
...@@ -23,30 +23,37 @@ describe('app dir', () => { ...@@ -23,30 +23,37 @@ describe('app dir', () => {
describe('HMR', () => { describe('HMR', () => {
it('should not cause error when removing loading.js', async () => { it('should not cause error when removing loading.js', async () => {
const browser = await next.browser('/page-with-loading') const browser = await next.browser('/page-with-loading')
await check(
() => browser.elementByCss('h1').text(), await retry(async () => {
'hello from slow page' const headline = await browser.elementByCss('h1').text()
) expect(headline).toBe('hello from slow page')
})
const cliOutputLength = next.cliOutput.length
await next.renameFile( await next.renameFile(
'app/page-with-loading/loading.js', 'app/page-with-loading/loading.js',
'app/page-with-loading/_loading.js' 'app/page-with-loading/_loading.js'
) )
await waitFor(1000) await retry(async () => {
expect(next.cliOutput.slice(cliOutputLength)).toInclude('✓ Compiled')
})
// It should not have an error // It should not have an error
await assertNoRedbox(browser) await assertNoRedbox(browser)
// HMR should still work // HMR should still work
const code = await next.readFile('app/page-with-loading/page.js')
await next.patchFile( await next.patchFile(
'app/page-with-loading/page.js', 'app/page-with-loading/page.js',
code.replace('hello from slow page', 'hello from new page') (content) =>
) content.replace('hello from slow page', 'hello from new page'),
await check( async () =>
() => browser.elementByCss('h1').text(), retry(async () => {
'hello from new page' const headline = await browser.elementByCss('h1').text()
expect(headline).toBe('hello from new page')
await browser.close()
})
) )
}) })
}) })
......
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