Mudlej.com has a Vitest test suite around the content model, Markdown pipeline, generated HTML, metadata, feeds, runtime loading, accessibility behavior, and structural snapshots.

Example Run#

The full command runs the Astro build first, then runs Vitest. The build output is omitted here so the test result is easier to read.

Terminal window
> pnpm run test
> mudlej-dotcom@1.0.0 test mudlej-dotcom
> astro build && vitest run tests
RUN v4.1.8 mudlej-dotcom
content-pages.test.ts (4 tests) 5ms
sitemap-rules.test.ts (4 tests) 4ms
metadata.test.ts (5 tests) 4ms
rss.test.ts (3 tests) 3ms
projects.test.ts (6 tests) 5ms
articles.test.ts (10 tests) 16ms
feeds.test.ts (2 tests) 11ms
remark-mermaid.test.ts (2 tests) 9ms
remark-inline-formatting.test.ts (2 tests) 9ms
remark-abbreviations.test.ts (2 tests) 13ms
remark-content-tabs.test.ts (3 tests) 18ms
accessibility.test.ts (3 tests) 42ms
remark-reading-time.test.ts (1 test) 7ms
remark-internal-links.test.ts (7 tests) 21ms
rendering-fragments.test.ts (2 tests) 30ms
snapshots.test.ts (2 tests) 27ms
runtimes.test.ts (3 tests) 39ms
pages.test.ts (5 tests) 41ms
theme.test.ts (7 tests) 7ms
reader-settings.test.ts (5 tests) 8ms
content-image-lightbox.test.ts (1 test) 9ms
metadata.test.ts (2 tests) 57ms
links.test.ts (4 tests) 114ms
Test Files 23 passed (23)
Tests 85 passed (85)
Duration 346ms

Test Types#

Unit Tests#

Unit tests cover pure helpers and small browser-facing runtimes. They make sure the content model, metadata helpers, reader controls, theme controls, and project/article data helpers behave predictably before any full page is generated.

tests/unit/articles.test.ts#

#TestWhy it exists
1Builds stable article and series URLs.Keeps generated article and series links predictable.
2Uses published, updated, then created date for display.Preserves the site’s date priority rules.
3Keeps draft articles visible in dev but hidden in production.Prevents drafts from leaking into production.
4Uses series metadata visibility to hide whole series in production.Ensures draft series hide their attached articles.
5Formats dates and series steps with site conventions.Keeps ISO dates and numbered series steps stable.
6Groups and sorts series articles by series order.Keeps roadmap and series pages in author-defined order.
7Throws when a series article references missing series metadata.Turns broken series references into early failures.
8Creates index data without listing series articles as standalone articles.Keeps the article index from duplicating series content.
9Creates previous/next navigation and current-position legend for series articles.Protects series navigation and step indicators.
10Builds searchable text from article and series fields.Keeps article index filtering data complete.

tests/unit/projects.test.ts#

#TestWhy it exists
1Builds project URLs and formats lifecycle labels.Keeps project links and lifecycle copy stable.
2Sorts projects by lifecycle, date, then title.Preserves the project index ordering rules.
3Maps lifecycle tones.Keeps project lifecycle badges visually consistent.
4Keeps draft projects visible in dev but hidden in production.Prevents draft projects from leaking into production.
5Selects primary source and user-facing project URLs.Keeps project cards and detail links pointed at the right targets.
6Builds project search text from summary fields.Keeps future project filtering/search data complete.

tests/unit/content-pages.test.ts#

#TestWhy it exists
1Formats dates as ISO calendar dates.Keeps project and supplement date formatting consistent.
2Detects Mermaid fences and content tabs directives.Loads page runtimes only when matching content exists.
3Detects Markdown and raw HTML content images.Enables image lightbox behavior only on image-rich pages.
4Keeps TOC headings from depth 1 through 3 except footnotes.Keeps tables of contents useful and avoids footnote noise.

tests/unit/content-image-lightbox.test.ts#

#TestWhy it exists
1Enhances eligible rich-content images and opens an accessible lightbox.Protects image preview behavior and controls.

tests/unit/theme.test.ts#

#TestWhy it exists
1Validates themes and theme preferences.Rejects invalid theme values.
2Resolves system theme preferences from matchMedia.Keeps system theme behavior correct.
3Reads valid stored preferences and ignores invalid values.Prevents bad local storage values from breaking theme state.
4Applies theme classes, attributes, and color scheme.Keeps light/dark mode wiring consistent.
5Applies and resolves theme preferences.Protects initial theme preference behavior.
6Cycles preferences in the configured order.Keeps the theme toggle predictable.
7Stores preference and dispatches theme-change events.Keeps persistence and runtime notifications working.

tests/unit/reader-settings.test.ts#

#TestWhy it exists
1Validates reader setting values and names.Rejects invalid text-size and width settings.
2Parses stored settings with default fallback for invalid fields.Prevents bad stored reader settings from breaking the page.
3Stores, resolves, and applies reader settings.Keeps text-size and width settings persistent.
4Updates one setting while preserving the other.Prevents one reader control from resetting another.
5Syncs aria-pressed on reader setting controls.Keeps reader controls accessible and truthful.

tests/unit/metadata.test.ts#

#TestWhy it exists
1Extracts reading time metadata defensively.Prevents malformed reading-time data from leaking into metadata.
2Builds absolute URLs against the site URL.Keeps canonical, image, and feed URLs absolute.
3Formats page titles without duplicating the site name.Keeps title metadata clean.
4Maps page metadata to schema and Open Graph types.Keeps structured data and social metadata semantically correct.
5Derives robots metadata from draft visibility or explicit robots setting.Keeps indexing behavior explicit.

tests/unit/rss.test.ts#

#TestWhy it exists
1Filters draft articles and draft-series articles, then sorts by feed date.Keeps RSS public and correctly ordered.
2Uses published, updated, then created date for RSS dates.Preserves feed date priority rules.
3Maps article entries to RSS item data.Keeps RSS item titles, descriptions, dates, links, and categories correct.

tests/unit/sitemap-rules.test.ts#

#TestWhy it exists
1Extracts sitemap-relevant article frontmatter.Reads article visibility and series data for sitemap filtering.
2Extracts sitemap-relevant series JSON metadata.Reads series visibility for sitemap filtering.
3Builds draft article and series path sets from synthetic entries.Creates the exclusion lists used by sitemap rules.
4Normalizes sitemap paths and excludes drafts and supplements.Keeps private and unlisted pages out of the sitemap.

Markdown Tests#

Markdown tests focus on the custom remark/rehype behavior that makes the writing system richer than plain Markdown.

tests/markdown/remark-reading-time.test.ts#

#TestWhy it exists
1Writes display and numeric reading time into Astro frontmatter data.Keeps reading-time metadata available to article pages and indexes.

tests/markdown/remark-mermaid.test.ts#

#TestWhy it exists
1Converts Mermaid fences to raw pre.mermaid HTML.Prevents diagrams from being treated as highlighted code blocks.
2Leaves non-Mermaid code fences as code blocks.Protects normal fenced code behavior.

tests/markdown/remark-internal-links.test.ts#

#TestWhy it exists
1Resolves articles, series, projects, and supplement links.Keeps wiki-style internal links usable across content types.
2Resolves supplement links relative to project source files.Makes project supplements easy to link from project pages.
3Resolves supplement links relative to article supplement source files.Keeps relative supplement links working inside article supplements.
4Resolves supplement links relative to project supplement source files.Keeps relative supplement links working inside project supplements.
5Does not rewrite double brackets inside normal Markdown links.Avoids corrupting external URLs or literal examples.
6Throws useful errors for unsupported and missing targets.Makes broken links fail with actionable messages.
7Treats draft article links as broken in production builds.Prevents production pages from linking to hidden drafts.

tests/markdown/remark-inline-formatting.test.ts#

#TestWhy it exists
1Renders highlight, underline, and keyboard shortcuts.Protects custom inline formatting syntax.
2Ignores malformed empty inline markers.Prevents empty markers from creating bad HTML.

tests/markdown/remark-abbreviations.test.ts#

#TestWhy it exists
1Removes abbreviation definitions and wraps matching terms.Keeps abbreviation syntax clean in rendered HTML.
2Escapes abbreviation titles and respects word boundaries.Prevents unsafe titles and false-positive abbreviations.

tests/markdown/remark-content-tabs.test.ts#

#TestWhy it exists
1Turns tabs directives into accessible tab markup.Protects the generated ARIA structure for content tabs.
2Forces tabbed code blocks to render as code frames.Keeps code tabs visually integrated.
3Requires source Markdown tabbed code blocks to set frame="code" explicitly.Enforces a source-content convention across authored files.

tests/markdown/rendering-fragments.test.ts#

#TestWhy it exists
1Renders rich inline and block features through the combined pipeline.Catches plugin-order regressions across multiple features.
2Renders tabs fragments with stable ARIA relationships.Keeps generated tab IDs, controls, and panels stable.

Generated HTML Tests#

Generated HTML tests inspect the built dist/ output. They catch regressions that only appear after Astro content rendering, routing, metadata, and build-time integrations run together.

tests/dist/pages.test.ts#

#TestWhy it exists
1Renders article chrome and series context when the maintenance series is public.Protects article layout, metadata, TOC, boundaries, and series legend output.
2Renders series pages with articles in roadmap order when the maintenance series is public.Keeps generated series roadmaps ordered correctly.
3Renders supplements as unlisted support pages without article series UI.Ensures supplements stay noindex and do not inherit article-only UI.
4Omits draft articles from production output.Verifies production builds hide draft articles.
5Renders project index and detail pages when project content exists.Protects project archive and project detail rendering.

tests/dist/feeds.test.ts#

#TestWhy it exists
1Generates an RSS feed without draft articles.Keeps RSS public and article-only.
2Generates sitemap files that exclude drafts and supplements.Keeps private and unlisted content out of sitemaps.

tests/dist/metadata.test.ts#

#TestWhy it exists
1Emits required metadata on every generated HTML page.Ensures titles, descriptions, canonicals, Open Graph, Twitter, and JSON-LD exist.
2Keeps indexing rules explicit for supplements and public pages.Prevents accidental noindex on public pages and enforces it on supplements.

tests/dist/links.test.ts#

#TestWhy it exists
1Does not emit duplicate IDs on any page.Prevents broken anchors and invalid HTML IDs.
2Adds alt text to every generated image.Catches missing image accessibility text.
3Does not contain broken local links.Catches broken page links and broken hash anchors in built HTML.
4Opens external links in new tabs safely.Enforces target="_blank" with safe rel values.

tests/dist/runtimes.test.ts#

#TestWhy it exists
1Loads Mermaid runtime only on pages with diagrams.Keeps diagram JavaScript off pages that do not need it.
2Loads content-tabs runtime only on pages with content tabs.Keeps tabs JavaScript off pages that do not need it.
3Loads image lightbox runtime only on pages with content images.Keeps lightbox JavaScript off image-free pages.

tests/dist/accessibility.test.ts#

#TestWhy it exists
1Treats reader settings as a disclosure popover, not an unmanaged dialog.Protects reader settings semantics.
2Makes content tab panels programmatically focusable.Keeps tab panels keyboard-accessible.
3Renders image lightbox dialog controls on image-rich content pages.Protects lightbox labels, close controls, and image semantics.

tests/dist/snapshots.test.ts#

#TestWhy it exists
1Keeps the rendering preview structure stable.Uses a normalized full-page snapshot as a Markdown rendering canary.
2Keeps the styleguide structure stable.Uses a normalized full-page snapshot as a design-system canary.

Why This Exists#

The test suite is intentionally layered. Small unit tests catch content and runtime logic regressions close to the source. Markdown tests protect the custom writing syntax. Generated HTML tests verify the actual static output that ships. Snapshot canaries give broad coverage for the two pages most likely to reveal rendering and design-system regressions.

Together, they make Mudlej.com safer to change without turning it into a heavy application or adding browser/system-package test dependencies.