fix: update astro dev global-setup with astro:content mock for vitest to improve consistency#691
fix: update astro dev global-setup with astro:content mock for vitest to improve consistency#691zastrowm wants to merge 1 commit into
Conversation
Documentation Preview ReadyYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-cms-691/docs/user-guide/quickstart/overview/ Updated at: 2026-03-20T22:13:33.981Z |
Updated Review (v3 of PR)Assessment: ✅ Approve The core fix is sound — aliasing Review DetailsWhat changed from earlier versions:
Current approach:
Suggestion (non-blocking): Consider adding a brief comment in // globalSetup populates .astro/data-store.json if missing
// alias mocks astro:content since the virtual module doesn't resolve in vitestThe mock implementation itself is well-designed and the fix is valid. Approving as-is. |
37862e2 to
edfe59c
Compare
|
This repository has been merged into the strands-agents/harness-sdk monorepo and will be archived shortly. All new development happens there. If this PR is still relevant, please recreate it against the monorepo. The code now lives under Apologies for the disruption, and thank you for contributing! |
Description
Tests that call
getCollection()fromastro:contentwere broken in vitest becauseastro:contentis a Vite virtual module — it only resolves inside Astro's build pipeline and depending on the version of astro may not work in tests.The fix aliases
astro:contentin vitest to a lightweight mock (test/__mocks__/astro-content.ts) that reads.astro/data-store.jsondirectly usingdevalue.unflatten— the same serialization format Astro uses internally — and implementsgetCollection/getEntryagainst that in-memory map.The
global-setup.tsis kept to populate the data store when it doesn't exist (e.g. fresh CI checkout) or local development.astro syncwas investigated as a lighter alternative but does not produce the data store. The setup is skipped when the data store is already present, so local re-runs are fast.The
__*__/gitignore pattern that was inadvertently suppressing the__mocks__directory is also removed.Related Issues
N/A
Type of Change
Checklist
npm run devBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.