[PR #319] [MERGED] test: add unit tests for next/document shim #475

Closed
opened 2026-05-06 13:08:16 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/319
Author: @NathanDrake2406
Created: 3/7/2026
Status: Merged
Merged: 3/7/2026
Merged by: @james-elicx

Base: mainHead: test/document-shim-coverage


📝 Commits (1)

  • 5d79dc1 test: add unit tests for next/document shim components

📊 Changes

1 file changed (+101 additions, -0 deletions)

View changed files

tests/document.test.ts (+101 -0)

📄 Description

Summary

  • Adds 5 focused tests for the next/document shim components (Main, NextScript, Head, default Document)
  • Tests the contracts the Pages Router dev-server depends on, not React rendering:
    • Main renders id="__next" with __NEXT_MAIN__ placeholder (dev-server replaces with page content)
    • NextScript renders <!-- __NEXT_SCRIPTS__ --> comment (dev-server replaces with hydration scripts)
    • Head injects default charset + viewport meta, preserves custom children
    • Default Document assembles all sub-components in the correct nesting order (head < body < main < scripts)

Test plan

  • npx vitest run tests/document.test.ts — 5/5 passing
  • CI: Lint, Typecheck, Vitest, Playwright E2E

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/319 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/7/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `test/document-shim-coverage` --- ### 📝 Commits (1) - [`5d79dc1`](https://github.com/cloudflare/vinext/commit/5d79dc16526d4ad40ded58167274bcf832b3d72a) test: add unit tests for next/document shim components ### 📊 Changes **1 file changed** (+101 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `tests/document.test.ts` (+101 -0) </details> ### 📄 Description ## Summary - Adds 5 focused tests for the `next/document` shim components (`Main`, `NextScript`, `Head`, default `Document`) - Tests the **contracts** the Pages Router dev-server depends on, not React rendering: - `Main` renders `id="__next"` with `__NEXT_MAIN__` placeholder (dev-server replaces with page content) - `NextScript` renders `<!-- __NEXT_SCRIPTS__ -->` comment (dev-server replaces with hydration scripts) - `Head` injects default charset + viewport meta, preserves custom children - Default `Document` assembles all sub-components in the correct nesting order (head < body < main < scripts) ## Test plan - [x] `npx vitest run tests/document.test.ts` — 5/5 passing - [x] CI: Lint, Typecheck, Vitest, Playwright E2E --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:16 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#475
No description provided.