react-code-dataset / next.js /test /development /app-dir /cache-components-dev-warmup /cache-components.dev-warmup.test.ts
Download next.js/test/development/app-dir/cache-components-dev-warmup/cache-components.dev-warmup.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/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/next.js/test/development/app-dir/cache-components-dev-warmup/cache-components.dev-warmup.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/next.js/test/development/app-dir/cache-components-dev-warmup/cache-components.dev-warmup.test.ts
-
curl -L -o cache-components.dev-warmup.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/next.js/test/development/app-dir/cache-components-dev-warmup/cache-components.dev-warmup.test.ts
1.67 kB
| import { nextTestSetup } from 'e2e-utils' | |
| describe('cache-components-dev-warmup', () => { | |
| const { next } = nextTestSetup({ | |
| files: __dirname, | |
| }) | |
| function assertLog( | |
| logs: Array<{ source: string; message: string }>, | |
| message: string, | |
| environment: string | |
| ) { | |
| expect(logs.map((l) => l.message)).toEqual( | |
| expect.arrayContaining([ | |
| expect.stringMatching( | |
| new RegExp(`^(?=.*\\b${message}\\b)(?=.*\\b${environment}\\b).*`) | |
| ), | |
| ]) | |
| ) | |
| } | |
| it('logs with Prerender or Server environment depending based on whether the timing of when the log runs relative to this environment boundary', async () => { | |
| let browser = await next.browser('/') | |
| let logs = await browser.log() | |
| assertLog(logs, 'after layout cache read', 'Prerender') | |
| assertLog(logs, 'after page cache read', 'Prerender') | |
| assertLog(logs, 'after cached layout fetch', 'Prerender') | |
| assertLog(logs, 'after cached page fetch', 'Prerender') | |
| assertLog(logs, 'after uncached layout fetch', 'Server') | |
| assertLog(logs, 'after uncached page fetch', 'Server') | |
| // After a revalidation the subsequent warmup render must discard stale | |
| // cache entries. | |
| await next.fetch('/revalidate') | |
| browser = await next.browser('/') | |
| logs = await browser.log() | |
| assertLog(logs, 'after layout cache read', 'Prerender') | |
| assertLog(logs, 'after page cache read', 'Prerender') | |
| assertLog(logs, 'after cached layout fetch', 'Prerender') | |
| assertLog(logs, 'after cached page fetch', 'Prerender') | |
| assertLog(logs, 'after uncached layout fetch', 'Server') | |
| assertLog(logs, 'after uncached page fetch', 'Server') | |
| }) | |
| }) | |