GPU shader testing library for WGSL and WESL, version 0.6.46. Provides testCompute, testFragment, testFragmentImage, and expectFragmentImage to unit-test compute and fragment shaders directly from Node.js test frameworks like vitest. Supports visual regression testing via image snapshots. Designed to fill the gap in WebGPU testing tooling, akin to Jest snapshot testing for shaders. Ships TypeScript types. Peer dependencies on vitest ^3.2.4 and vitest-image-snapshot ^0.6.37. Active development with monthly releases.
npm install wesl-testNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Imports getGPUDevice and testCompute, runs a simple compute shader with one workgroup, and logs the result buffer.
Wrap in try-catch or check navigator.gpu before calling. Run tests only in environments with WebGPU.
Access results as numbers, or cast to Uint32Array if needed: new Uint32Array(result)
Migrate to expectFragmentImage and call imageMatcher() in setup.
Call imageMatcher() in a global setup file or setupFiles in vitest config.
Add "type": "module" to your package.json or use vitest --config with esm resolution.
Use getGPUDevice() inside a test or beforeAll, and ensure WebGPU is supported (Node with wgpu polyfill or browser with WebGPU).