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.
> mudlej-dotcom@1.0.0 test mudlej-dotcom
> astro build && vitest run tests
✓ 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)
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#
# Test Why it exists 1 Builds stable article and series URLs. Keeps generated article and series links predictable. 2 Uses published, updated, then created date for display. Preserves the site’s date priority rules. 3 Keeps draft articles visible in dev but hidden in production. Prevents drafts from leaking into production. 4 Uses series metadata visibility to hide whole series in production. Ensures draft series hide their attached articles. 5 Formats dates and series steps with site conventions. Keeps ISO dates and numbered series steps stable. 6 Groups and sorts series articles by series order. Keeps roadmap and series pages in author-defined order. 7 Throws when a series article references missing series metadata. Turns broken series references into early failures. 8 Creates index data without listing series articles as standalone articles. Keeps the article index from duplicating series content. 9 Creates previous/next navigation and current-position legend for series articles. Protects series navigation and step indicators. 10 Builds searchable text from article and series fields. Keeps article index filtering data complete.
tests/unit/projects.test.ts#
# Test Why it exists 1 Builds project URLs and formats lifecycle labels. Keeps project links and lifecycle copy stable. 2 Sorts projects by lifecycle, date, then title. Preserves the project index ordering rules. 3 Maps lifecycle tones. Keeps project lifecycle badges visually consistent. 4 Keeps draft projects visible in dev but hidden in production. Prevents draft projects from leaking into production. 5 Selects primary source and user-facing project URLs. Keeps project cards and detail links pointed at the right targets. 6 Builds project search text from summary fields. Keeps future project filtering/search data complete.
tests/unit/content-pages.test.ts#
# Test Why it exists 1 Formats dates as ISO calendar dates. Keeps project and supplement date formatting consistent. 2 Detects Mermaid fences and content tabs directives. Loads page runtimes only when matching content exists. 3 Detects Markdown and raw HTML content images. Enables image lightbox behavior only on image-rich pages. 4 Keeps 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#
# Test Why it exists 1 Enhances eligible rich-content images and opens an accessible lightbox. Protects image preview behavior and controls.
tests/unit/theme.test.ts#
# Test Why it exists 1 Validates themes and theme preferences. Rejects invalid theme values. 2 Resolves system theme preferences from matchMedia. Keeps system theme behavior correct. 3 Reads valid stored preferences and ignores invalid values. Prevents bad local storage values from breaking theme state. 4 Applies theme classes, attributes, and color scheme. Keeps light/dark mode wiring consistent. 5 Applies and resolves theme preferences. Protects initial theme preference behavior. 6 Cycles preferences in the configured order. Keeps the theme toggle predictable. 7 Stores preference and dispatches theme-change events. Keeps persistence and runtime notifications working.
tests/unit/reader-settings.test.ts#
# Test Why it exists 1 Validates reader setting values and names. Rejects invalid text-size and width settings. 2 Parses stored settings with default fallback for invalid fields. Prevents bad stored reader settings from breaking the page. 3 Stores, resolves, and applies reader settings. Keeps text-size and width settings persistent. 4 Updates one setting while preserving the other. Prevents one reader control from resetting another. 5 Syncs aria-pressed on reader setting controls. Keeps reader controls accessible and truthful.
# Test Why it exists 1 Extracts reading time metadata defensively. Prevents malformed reading-time data from leaking into metadata. 2 Builds absolute URLs against the site URL. Keeps canonical, image, and feed URLs absolute. 3 Formats page titles without duplicating the site name. Keeps title metadata clean. 4 Maps page metadata to schema and Open Graph types. Keeps structured data and social metadata semantically correct. 5 Derives robots metadata from draft visibility or explicit robots setting. Keeps indexing behavior explicit.
# Test Why it exists 1 Filters draft articles and draft-series articles, then sorts by feed date. Keeps RSS public and correctly ordered. 2 Uses published, updated, then created date for RSS dates. Preserves feed date priority rules. 3 Maps article entries to RSS item data. Keeps RSS item titles, descriptions, dates, links, and categories correct.
tests/unit/sitemap-rules.test.ts#
# Test Why it exists 1 Extracts sitemap-relevant article frontmatter. Reads article visibility and series data for sitemap filtering. 2 Extracts sitemap-relevant series JSON metadata. Reads series visibility for sitemap filtering. 3 Builds draft article and series path sets from synthetic entries. Creates the exclusion lists used by sitemap rules. 4 Normalizes 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.
# Test Why it exists 1 Writes display and numeric reading time into Astro frontmatter data. Keeps reading-time metadata available to article pages and indexes.
# Test Why it exists 1 Converts Mermaid fences to raw pre.mermaid HTML. Prevents diagrams from being treated as highlighted code blocks. 2 Leaves non-Mermaid code fences as code blocks. Protects normal fenced code behavior.
# Test Why it exists 1 Resolves articles, series, projects, and supplement links. Keeps wiki-style internal links usable across content types. 2 Resolves supplement links relative to project source files. Makes project supplements easy to link from project pages. 3 Resolves supplement links relative to article supplement source files. Keeps relative supplement links working inside article supplements. 4 Resolves supplement links relative to project supplement source files. Keeps relative supplement links working inside project supplements. 5 Does not rewrite double brackets inside normal Markdown links. Avoids corrupting external URLs or literal examples. 6 Throws useful errors for unsupported and missing targets. Makes broken links fail with actionable messages. 7 Treats draft article links as broken in production builds. Prevents production pages from linking to hidden drafts.
# Test Why it exists 1 Renders highlight, underline, and keyboard shortcuts. Protects custom inline formatting syntax. 2 Ignores malformed empty inline markers. Prevents empty markers from creating bad HTML.
# Test Why it exists 1 Removes abbreviation definitions and wraps matching terms. Keeps abbreviation syntax clean in rendered HTML. 2 Escapes abbreviation titles and respects word boundaries. Prevents unsafe titles and false-positive abbreviations.
# Test Why it exists 1 Turns tabs directives into accessible tab markup. Protects the generated ARIA structure for content tabs. 2 Forces tabbed code blocks to render as code frames. Keeps code tabs visually integrated. 3 Requires source Markdown tabbed code blocks to set frame="code" explicitly. Enforces a source-content convention across authored files.
tests/markdown/rendering-fragments.test.ts#
# Test Why it exists 1 Renders rich inline and block features through the combined pipeline. Catches plugin-order regressions across multiple features. 2 Renders 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#
# Test Why it exists 1 Renders article chrome and series context when the maintenance series is public. Protects article layout, metadata, TOC, boundaries, and series legend output. 2 Renders series pages with articles in roadmap order when the maintenance series is public. Keeps generated series roadmaps ordered correctly. 3 Renders supplements as unlisted support pages without article series UI. Ensures supplements stay noindex and do not inherit article-only UI. 4 Omits draft articles from production output. Verifies production builds hide draft articles. 5 Renders project index and detail pages when project content exists. Protects project archive and project detail rendering.
tests/dist/feeds.test.ts#
# Test Why it exists 1 Generates an RSS feed without draft articles. Keeps RSS public and article-only. 2 Generates sitemap files that exclude drafts and supplements. Keeps private and unlisted content out of sitemaps.
# Test Why it exists 1 Emits required metadata on every generated HTML page. Ensures titles, descriptions, canonicals, Open Graph, Twitter, and JSON-LD exist. 2 Keeps indexing rules explicit for supplements and public pages. Prevents accidental noindex on public pages and enforces it on supplements.
tests/dist/links.test.ts#
# Test Why it exists 1 Does not emit duplicate IDs on any page. Prevents broken anchors and invalid HTML IDs. 2 Adds alt text to every generated image. Catches missing image accessibility text. 3 Does not contain broken local links. Catches broken page links and broken hash anchors in built HTML. 4 Opens external links in new tabs safely. Enforces target="_blank" with safe rel values.
tests/dist/runtimes.test.ts#
# Test Why it exists 1 Loads Mermaid runtime only on pages with diagrams. Keeps diagram JavaScript off pages that do not need it. 2 Loads content-tabs runtime only on pages with content tabs. Keeps tabs JavaScript off pages that do not need it. 3 Loads image lightbox runtime only on pages with content images. Keeps lightbox JavaScript off image-free pages.
tests/dist/accessibility.test.ts#
# Test Why it exists 1 Treats reader settings as a disclosure popover, not an unmanaged dialog. Protects reader settings semantics. 2 Makes content tab panels programmatically focusable. Keeps tab panels keyboard-accessible. 3 Renders image lightbox dialog controls on image-rich content pages. Protects lightbox labels, close controls, and image semantics.
tests/dist/snapshots.test.ts#
# Test Why it exists 1 Keeps the rendering preview structure stable. Uses a normalized full-page snapshot as a Markdown rendering canary. 2 Keeps 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.
End