Skip to content

Commit

Permalink
Put flaky use-cache-unknown-cache-kind dev tests in sandboxes (#76171)
Browse files Browse the repository at this point in the history
Apparently the HMR changes in the one dev test are affecting the others,
or vice versa. So we put them in sandboxes to hopefully avoid the
resulting flakiness.
  • Loading branch information
unstubbable authored Feb 18, 2025
1 parent c43d73d commit bd9b11e
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
retry,
} from 'next-test-utils'
import stripAnsi from 'strip-ansi'
import { createSandbox } from 'development-sandbox'

const nextConfigWithCacheHandler: NextConfig = {
experimental: {
Expand Down Expand Up @@ -88,12 +89,14 @@ describe('use-cache-unknown-cache-kind', () => {
})
} else {
it('should not show an error for default cache kinds', async () => {
const browser = await next.browser('/remote')
await using sandbox = await createSandbox(next, undefined, '/remote')
const { browser } = sandbox
await assertNoRedbox(browser)
})

it('should show a build error', async () => {
const browser = await next.browser('/')
await using sandbox = await createSandbox(next, undefined, '/')
const { browser } = sandbox

await assertHasRedbox(browser)

Expand Down Expand Up @@ -161,19 +164,20 @@ describe('use-cache-unknown-cache-kind', () => {
})

it('should recover from the build error if the cache handler is defined', async () => {
const browser = await next.browser('/')
await using sandbox = await createSandbox(next, undefined, '/')
const { browser, session } = sandbox

await assertHasRedbox(browser)

await next.patchFile(
await session.patch(
'next.config.js',
`module.exports = ${JSON.stringify(nextConfigWithCacheHandler)}`,
() =>
retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('hello world')
await assertNoRedbox(browser)
})
`module.exports = ${JSON.stringify(nextConfigWithCacheHandler)}`
)

await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('hello world')
await assertNoRedbox(browser)
})
})
}
})
Expand Down

0 comments on commit bd9b11e

Please sign in to comment.