Download next.js/test/development/app-hmr/hmr-env.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/app-hmr/hmr-env.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/development/app-hmr/hmr-env.test.ts
-
curl -L -o hmr-env.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/app-hmr/hmr-env.test.ts
1.67 kB
| 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') | |
| } | |
| ) | |
| }) | |