Skip to content

Testing

Unit Testing

Coverage

Coverage reports are generated by Vitest via v8, and are available in multiple formats. SvelTeX currently has 100% coverage, meaning that every line of code and every branch is either tested, or includes a comment explaining why the line is unreachable (such code is sometimes included for redundancy in error-checking).

Keeping coverage at 100% is a medium-priority goal. Though the relatively small size of the project's codebase makes it a perfectly feasible goal, a strict 100% coverage requirement can have many negative unintended consequences, including decreased developer productivity, a false sense of security, and premature rigidity in the codebase.

CommonMark (non-)compliance

Each of the four supported markdown backends is tested against a substantial subset of the CommonMark test suite. However, two sections are skipped entirely ("Indented code blocks" and "Autolinks"), and several other tests are skipped on a case-by-case basis as well. Furthermore, SvelTeX's output and the expected output are both normalized before comparison. I opted for this relaxed approach with respect to the CommonMark test suite because SvelTeX doesn't aim to fully comply with CommonMark. Nonetheless, even with these caveats CommonMark's test suite is an incredibly valuable resource for catching unexpected behavior, and as such it is a cornerstone of the project's testing strategy.

Fuzzy Testing

I'm progressively adding more fuzzy tests with the excellent fast-check library and its Vitest plugin. These tests are particularly useful for catching overlooked edge cases that one might not think to test for explicitly.

E2E Visual Regression Testing

End-to-end (E2E) visual regression testing is performed with Playwright.