Rust & WebAssembly · Patterns
Testing WASM Parity
Asserting the WASM and TS implementations agree.
1 min readPublished Updated
- testing
- wasm
Parity tests assert that the WASM implementation and the TypeScript fallback produce the same results.
ts
test("cosine similarity matches between engines", () => {
expect(wasmCosine(a, b)).toBeCloseTo(tsCosine(a, b), 6);
});Skip these tests when the compiled .wasm artifact isn't present, so a fresh clone without the Rust toolchain still passes CI.