File size: 1,666 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import { FileRef, nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import path from 'path'
const envFile = '.env.development.local'
describe(`app-dir hmr-env`, () => {
const { next } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
patchFileDelay: 1000,
})
it.each(['node', 'node-module-var', 'edge', 'edge-module-var'])(
'should update server components pages when env files is changed (%s)',
async (page) => {
const browser = await next.browser(`/env/${page}`)
expect(await browser.elementByCss('p').text()).toBe('mac')
await next.patchFile(envFile, 'MY_DEVICE="ipad"', async () => {
let logs
await retry(async () => {
logs = await browser.log()
expect(logs).toEqual(
expect.arrayContaining([
expect.objectContaining({
message: expect.stringContaining('[Fast Refresh] done'),
source: 'log',
}),
])
)
})
await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('ipad')
})
expect(logs).toEqual(
expect.arrayContaining([
expect.objectContaining({
message: expect.stringContaining('[Fast Refresh] done in'),
source: 'log',
}),
])
)
})
// ensure it's restored back to "mac" before the next test
await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('mac')
})
expect(next.cliOutput).not.toContain('FATAL')
}
)
})
|