Testing
Strudel uses vitest for testing, with 2 types of testing strategies:
- unit tests for fine grained testing
- automated snapshot tests for broader testing
Unit Tests
Each package has a test
folder where tests are written on a file by file basis, e.g. util.test.mjs
implements all tests for util.mjs
.
Snapshot Tests
Snapshot tests allow testing larger chunks of data. Strudel uses snapshot tests for:
- Example Snippets:
examples.test.mjs
, using snippets under@example
inside jsdoc comments - Example Tunes:
tunes.test.mjs
, using all patterns intunes.mjs
The snapshot (.snap
) files contain all haps within a certain number of cycles for each tested pattern.
They allow testing for breaking changes on a larger scale.
If breaking changes are intentional, the snapshots can be updated with npm run snapshot
.
Just make sure to verify that all affected patterns behave as expected.