|
|
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', |
|
|
}), |
|
|
]) |
|
|
) |
|
|
}) |
|
|
|
|
|
|
|
|
await retry(async () => { |
|
|
expect(await browser.elementByCss('p').text()).toBe('mac') |
|
|
}) |
|
|
|
|
|
expect(next.cliOutput).not.toContain('FATAL') |
|
|
} |
|
|
) |
|
|
}) |
|
|
|