Skip to content

Make Content Layer unit testable#15659

Merged
ematipico merged 15 commits intomainfrom
cl-refactor
Feb 26, 2026
Merged

Make Content Layer unit testable#15659
ematipico merged 15 commits intomainfrom
cl-refactor

Conversation

@matthewp
Copy link
Contributor

Makes ContentLayer unit testable, it was already pretty close! Just needed a couple of features like being able to pass in a contentConfigObserver.

Changes

  • Constructor takes a ContentObservable so it can be provided by unit tests.
  • Moves the singleton to another file, this is what the rest of Astro uses.

Testing

  • Moved over tests suites:
    • content-layer.test.js
    • content-layer-render.test.js

Docs

N/A, just refactor and test changes

Makes ContentLayer unit testable, it was already pretty close! Just needed a couple of features like being able to pass in a contentConfigObserver.
@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: 2057181

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 25, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 25, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing cl-refactor (2057181) with main (7150a2e)

Open in CodSpeed

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Feb 25, 2026
@matthewp
Copy link
Contributor Author

All tests passing on b15e44b

Removing the integration tests now.

@matthewp matthewp marked this pull request as ready for review February 25, 2026 22:05
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Awesome!

@ematipico ematipico merged commit 844bdd4 into main Feb 26, 2026
27 checks passed
@ematipico ematipico deleted the cl-refactor branch February 26, 2026 17:34
jcayzac added a commit to jcayzac/astro that referenced this pull request Feb 27, 2026
…rrorMap formatting

The Standard Schema path (~standard.validate) bypasses Zod's errorMap, so
error messages for direct Zod schemas were produced without the path-prefixed
format (e.g. "**title**: Required") that errorMap applies.

Split the direct-schema branch in getEntryData: schemas with _zod use
safeParseAsync + errorMap as before; non-Zod Standard Schemas (Valibot,
ArkType, etc.) continue using ~standard.validate + formatIssues.

Fixes schema-validation unit test introduced in withastro#15659.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants