npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

wgsl-test

v0.2.1

Published

Write GPU shader tests as easily as regular unit tests. Test WGSL and WESL shaders with vitest or your favorite Node.js test framework.

Readme

wgsl-test

Write GPU shader tests as easily as regular unit tests. Test WGSL and WESL shaders with vitest or your favorite Node.js test framework.

  • Test WGSL shaders - Works with standard .wgsl files, no new syntax required
  • Test WESL shaders - Import and compose shader dependencies via WESL
  • Visual regression testing - Snapshot comparison catches rendering changes

Installation

npm install wgsl-test

Quick start in 3 steps:

  1. Write your shader function in WGSL or WESL as normal
  2. Use testCompute(), testFragment(), testFragmentImage(), or expectFragmentImage() to test your shader with inline source or from files
  3. Assert the results with your test framework

Testing Compute Shaders

The default choice for unit testing shader functions. Flexible and explicit.

Use testCompute() to test compute shader logic. A test::results buffer is automatically provided:

import { testCompute, getGPUDevice } from "wgsl-test";

const device = await getGPUDevice();

const src = `
  import package::hash::lowbias32;

  @compute @workgroup_size(1)
  fn main() {
    test::results[0] = lowbias32(0u);
    test::results[1] = lowbias32(42u);
  }
`;

const result = await testCompute({ device, src, size: 2 });
// result = [0, 388445122]

See API.md for complete API documentation →

Testing Fragment Shaders

For unit testing shader functions that only run in fragment shaders. Tests a single pixel output.

Use testFragment() to test fragment shader rendering.

/// shaders/foo.wesl
fn bar(p: vec4f) -> vec4f {
  return 2 * sqrt(p);
}
const src = `
  @fragment
  fn fs_main(@builtin(position) pos:vec4f) -> @location(0) vec4f {
    return foo::bar(pos * 2);
  }
`;

const result = await testFragment({ device, src });
// result = [2.828, 1.414, 0.0, 2.0]  // vec4f color at pixel (0,0)

See API.md for derivatives, input textures, uniforms, and more →

Visual Regression Testing

Higher level testing, good for regression. Tests don't provide much numeric descriptive value but catch visual changes automatically.

Test complete rendered images:

import { expectFragmentImage, imageMatcher } from "wgsl-test";

imageMatcher(); // Setup once

test("blur shader matches snapshot", async () => {
  await expectFragmentImage(device, "effects/blur.wgsl", {
    projectDir: import.meta.url,
    size: [256, 256],
  });
  // Snapshot automatically compared against __image_snapshots__/effects-blur.png
});

Snapshot comparison automatically detects rendering changes. Update snapshots with vitest -u when changes are intentional.

See API.md for snapshot workflow and visual regression testing →

API Documentation

Future

What would you like to see next in wgsl-test? Test scaffolding for vertex shaders? Annotations to put simple tests in WESL directly? Something else?

Please file an issue or talk about your ideas on the tooling group discord chat.