Skip to content

Document @fedify/fixture boundary and add a usage checker#747

Merged
dahlia merged 5 commits intofedify-dev:mainfrom
2chanhaeng:fixture
Apr 28, 2026
Merged

Document @fedify/fixture boundary and add a usage checker#747
dahlia merged 5 commits intofedify-dev:mainfrom
2chanhaeng:fixture

Conversation

@2chanhaeng
Copy link
Copy Markdown
Contributor

Closes #746.

Summary

  • Add a contributor-facing packages/fixture/README.md covering the four exports (test(), testDefinitions, mockDocumentLoader(), TestSpanExporter / createTestTracerProvider()), the fixture-tree convention, and the runtime-specific quirks (LogTape buffering, Bun and Node.js dispatch, the Cloudflare Workers .test hostname trick).
  • Add a “Writing tests with @fedify/fixture” section to CONTRIBUTING.md that summarises each export and states the boundary rule: imports of @fedify/fixture must stay in **/*.test.ts files because the package is private and absent from the published artifacts.
  • Add a mise run check:fixture-usage task backed by scripts/check_fixture_usage.ts. The script scans packages/<pkg>/src/ and points out any non-*.test.ts file that imports or re-exports from @fedify/fixture. It recognises every common import/export form (default, namespace, named, mixed, type-only, side-effect, re-exports, multi-line braces, subpath specifiers). It is wired into the aggregate mise run check.
  • Genuine exceptions live in an ALLOWLIST constant inside the script with an inline justification per entry. Current entries cover the cfworkers test-harness re-exports under packages/fedify/src/testing/ and a JSDoc @example mention in packages/testing/src/mq-tester.ts.

The checker is positioned as a contributor convenience, not as rigorous verification: dynamic import(), require(), indirect re-exports, and a *.test.ts file being re-exported from a shipped entry point are not detected. Both documents say so explicitly.

Test plan

  • mise run check:fixture-usage passes on the current tree.
  • mise run check runs the new task alongside the other checks.
  • Manually adding import "@fedify/fixture" to a non-*.test.ts file under packages/<pkg>/src/ causes the checker to fail with a pointer to that file.
  • Removing an ALLOWLIST entry while the corresponding file still imports @fedify/fixture causes the checker to fail.

Assisted-by: Claude Code:claude-opus-4-7

`@fedify/fixture` is a private workspace package — it is absent
from the published artifacts on npm and JSR, so any non-test file
that imports it would fail to resolve once the dependent package
is installed from a registry.  The convention is therefore to
keep `@fedify/fixture` confined to `**/*.test.ts` files.

To make that convention easier for contributors to follow, this
change adds a `mise run check:fixture-usage` task backed by a
small Deno script.  The script scans `packages/<pkg>/src/` and
points out any non-`*.test.ts` file that imports or re-exports
from `@fedify/fixture`, so a contributor catches the slip locally
before opening a PR.  The task is also wired into the aggregate
`mise run check` so it runs alongside the other code-quality
checks.

The script recognises every common import/export form (default,
namespace, named, mixed, type-only, side-effect, re-exports,
multi-line braces, and subpath specifiers).  It is intentionally
documented as a coarse textual scan: dynamic `import()`,
`require()`, indirect re-exports, and a `*.test.ts` file being
re-exported from a shipped entry point are not detected, so the
check is a convenience for contributors rather than a guarantee
for reviewers.

Genuine exceptions live in an `ALLOWLIST` constant inside the
script, with an inline comment per entry explaining the
justification.  The current entries cover the cfworkers test
harness re-exports in `packages/fedify/src/testing/` and a JSDoc
`@example` mention in `packages/testing/src/mq-tester.ts`.

Assisted-by: Claude Code:claude-opus-4-7
Add a README to packages/fixture/ that explains what the
package exports and how to use it from other workspace
packages, so new contributors can pick up the testing
infrastructure without reading every dependent test file
first.  The README walks through the four entry points
(`test()`, `testDefinitions`, `mockDocumentLoader()`, and
`TestSpanExporter` / `createTestTracerProvider()`), shows the
fixture-tree convention, and notes the runtime-specific
quirks (LogTape buffering, Bun and Node.js dispatch, the
Cloudflare Workers `.test` hostname trick).

Add a "Writing tests with @fedify/fixture" section to
CONTRIBUTING.md that points contributors at the new README,
gives a one-line summary per export, and spells out the
boundary rule: imports of `@fedify/fixture` must stay in
`**/*.test.ts` files because the package is private and
absent from the published artifacts.  Both documents
mention `mise run check:fixture-usage` as a convenience
check while making clear it is a coarse textual scan and
not a substitute for code review.

Assisted-by: Claude Code:claude-opus-4-7
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

Documents the monorepo-private @fedify/fixture package and enforces its boundary by adding contributor docs, a package README, a Deno script that detects non-test imports, and a mise task wired into the repository check task.

Changes

Cohort / File(s) Summary
Contributor docs
CONTRIBUTING.md
Documented @fedify/fixture usage, listed exported helpers, and added the rule that @fedify/fixture may only be imported from **/*.test.ts files.
Fixture README
packages/fixture/README.md
Added full README describing test(), testDefinitions, mockDocumentLoader(), OpenTelemetry test utilities, fixtures import path, logging, and the repository boundary rule.
Validation script
scripts/check_fixture_usage.ts
New Deno script that scans source files (excluding packages/fixture and *.test.ts) for @fedify/fixture import/export usages and exits non‑zero on violations; includes an allowlist.
Build/CI task
mise.toml
Added tasks."check:fixture-usage" running the Deno script and added it as a dependency of the aggregate check task.
Agent guidance
AGENTS.md
Inserted a short subsection showing how to write tests using @fedify/fixture and linked to CONTRIBUTING/fixture README.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type/documentation

Suggested reviewers

  • sij411
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: documenting the @fedify/fixture boundary and adding a usage checker script.
Description check ✅ Passed The description is directly related to the changeset, providing detailed context about documentation additions, the checker script, and the test plan.
Linked Issues check ✅ Passed All changes directly address issue #746: contributor documentation for @fedify/fixture added, boundary rule documented, checker script implemented with allowlist, and integration into mise tasks completed.
Out of Scope Changes check ✅ Passed All changes are in scope with issue #746. Documentation files (CONTRIBUTING.md, README.md, AGENTS.md), the checker script, and mise configuration are all aligned with the stated objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@issues-auto-labeler issues-auto-labeler Bot added component/build Build system and packaging component/cli CLI tools related component/testing Testing utilities (@fedify/testing) labels Apr 28, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new private workspace package, @fedify/fixture, to provide shared test infrastructure across the monorepo. It includes a test() wrapper for cross-runtime compatibility, a fixture-backed document loader, and OpenTelemetry testing utilities. To prevent accidental leaks of this private package into published artifacts, a new linting script scripts/check_fixture_usage.ts and a corresponding mise task have been added. Feedback focuses on correcting a misleading jsr: import specifier in the documentation and addressing potential issues with JSR source-based distribution where raw imports of the private package might persist in exported files.

Comment thread scripts/check_fixture_usage.ts
Comment thread packages/fixture/README.md Outdated
@dahlia dahlia added this to the Fedify 2.3 milestone Apr 28, 2026
@dahlia dahlia self-assigned this Apr 28, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/fixture/README.md`:
- Around line 109-113: The README currently implies the LogTape buffering/reset
behavior is universal; narrow the wording to state this applies only to Deno by
updating the sentence to something like "In Deno, test() configures LogTape
before every test and resets it afterwards" and mention that Node/Bun do not use
this Deno-specific branch; verify against the implementation in
packages/fixture/src/test.ts (look for the test() function and the LogTape
setup/reset logic) and ensure the README language references Deno and the
LOG=always environment variable only for that runtime.

In `@scripts/check_fixture_usage.ts`:
- Around line 73-83: The relative path computed with relative(projectRoot,
entry.path) (stored in rel) may contain OS-native backslashes on Windows,
causing allowed.has(rel) and rel.endsWith(".test.ts") checks to fail; normalize
rel to use forward slashes (replace backslashes with '/') before performing the
.endsWith and allowed.has checks so comparisons match the ALLOWLIST format used
elsewhere (e.g., ensure the code around entry/walk, relative, rel, and allowed
uses the canonicalized forward-slash rel).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 578faafc-2b8a-4d00-986c-bd8b0b3a98e0

📥 Commits

Reviewing files that changed from the base of the PR and between b4801a9 and 5b27414.

📒 Files selected for processing (4)
  • CONTRIBUTING.md
  • mise.toml
  • packages/fixture/README.md
  • scripts/check_fixture_usage.ts

Comment thread packages/fixture/README.md Outdated
Comment thread scripts/check_fixture_usage.ts
Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md
Comment thread packages/fixture/README.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

2chanhaeng and others added 3 commits April 28, 2026 11:39
Co-authored-by: Copilot <copilot@github.com>
Drop the misleading deno.json snippet from the fixture README:
the workspace already resolves @fedify/fixture from the in-tree
source at the repository root, so contributors do not need to
add an `imports` entry, and showing one suggested otherwise.

Scope the LogTape buffering note to Deno, since the Bun and
Node.js dispatchers do not configure LogTape, and replace the
two separate `LOG=always` invocations with the single
`mise run test:deno` form that contributors actually use.

Fix the JSR reference link to point at jsr.io (the canonical
host) rather than the jsr.dev redirect.

Drop the gratuitous spaces around the slash separating
`TestSpanExporter` and `createTestTracerProvider()` in
CONTRIBUTING.md so the pair reads as a single label.

Assisted-by: Claude Code:claude-opus-4-7
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/check_fixture_usage.ts`:
- Around line 79-85: The skip and match regexes used in the walk(packagesDir,
...) call are not separator-safe: walk yields absolute paths so the skip Regex
'^packages${SEPARATOR}fixture' never matches, and interpolating SEPARATOR into a
RegExp produces unescaped backslashes on Windows. Update the patterns used in
the walk call (the match and skip arrays) to use a platform-agnostic separator
character class like '[/\\]' (or build via a helper e.g., sepClass) instead of
interpolating SEPARATOR, and ensure the skip pattern targets paths that may be
absolute (e.g., include a preceding any-path component or use character-class
separators) so the skip actually matches fixture package paths when iterating
packagesDir.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 120e2c5c-44e7-4944-9eb1-b1e8ba6edd69

📥 Commits

Reviewing files that changed from the base of the PR and between 5b27414 and 63dd349.

📒 Files selected for processing (4)
  • AGENTS.md
  • CONTRIBUTING.md
  • packages/fixture/README.md
  • scripts/check_fixture_usage.ts

Comment thread scripts/check_fixture_usage.ts
@dahlia dahlia merged commit 9071ca0 into fedify-dev:main Apr 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/build Build system and packaging component/cli CLI tools related component/testing Testing utilities (@fedify/testing)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document @fedify/fixture boundary and add a usage checker

2 participants