Skip to content

Commit

Permalink
Fix flakiness of should not cause error when removing loading.js te…
Browse files Browse the repository at this point in the history
…st (#67978)
  • Loading branch information
unstubbable authored Jul 20, 2024
1 parent f4a8008 commit e0858ec
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions test/e2e/app-dir/app-compilation/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, check, waitFor } from 'next-test-utils'
import { assertNoRedbox, retry } from 'next-test-utils'

describe('app dir', () => {
const { next, isNextDev, isNextStart, skipped } = nextTestSetup({
Expand All @@ -23,30 +23,37 @@ describe('app dir', () => {
describe('HMR', () => {
it('should not cause error when removing loading.js', async () => {
const browser = await next.browser('/page-with-loading')
await check(
() => browser.elementByCss('h1').text(),
'hello from slow page'
)

await retry(async () => {
const headline = await browser.elementByCss('h1').text()
expect(headline).toBe('hello from slow page')
})

const cliOutputLength = next.cliOutput.length

await next.renameFile(
'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
await assertNoRedbox(browser)

// HMR should still work
const code = await next.readFile('app/page-with-loading/page.js')
await next.patchFile(
'app/page-with-loading/page.js',
code.replace('hello from slow page', 'hello from new page')
)
await check(
() => browser.elementByCss('h1').text(),
'hello from new page'
(content) =>
content.replace('hello from slow page', 'hello from new page'),
async () =>
retry(async () => {
const headline = await browser.elementByCss('h1').text()
expect(headline).toBe('hello from new page')
await browser.close()
})
)
})
})
Expand Down

0 comments on commit e0858ec

Please sign in to comment.