Guides
Testing
Nizel’s test suite protects the Markdown behavior documented for the package.
CommonMark Conformance
Nizel runs the full CommonMark 0.31 spec test suite:
npm run test:commonmark
This runs all 652 spec tests against the Nizel parser and reports pass/fail for each.
Detailed Report
For a section-by-section breakdown:
npm run test:commonmark:report
Unit Tests
Vitest unit tests cover Nizel-specific features beyond the spec:
- frontmatter extraction
- template variable resolution
- filter application
- element customization
- plugin hooks
- preset behavior
- metadata collection
npm run test
Writing Tests
Tests use Vitest. Example:
import { describe, it, expect } from 'vitest';
import { useNizel } from 'nizel';
describe('frontmatter', () => {
it('extracts YAML frontmatter', async () => {
const nizel = useNizel();
const { meta } = await nizel(`
---
title: Test
---
Content.
`);
expect(meta.title).toBe('Test');
});
});
Conformance Runner
The CommonMark conformance runner lives at:
packages/nizel/conformance/commonmark-spec-runner.mjs
It loads tests from commonmark-spec, runs them through useNizel().parse() and render(), and compares the HTML output.