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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@corekraft/vitest-plugin-lwc

v1.1.0

Published

Vitest plugin for lwc/ salesforce/ lightning web components

Readme

@corekraft/vitest-plugin-lwc

Vitest plugin for testing Lightning Web Components in Salesforce projects.

Setup

Create vitest.config.mjs:

import { defineConfig } from "vitest/config";
import lwc from "@corekraft/vitest-plugin-lwc";

export default defineConfig({
  plugins: [lwc()],
});

This configuration is all you need as a starting vitest configuration. Follow #package-scripts

Package Scripts

Add or modify your test script in your package.json. Follow #running

{
  "scripts": {
    "test:unit": "vitest run"
  }
}

Running

Then run:

npm test:unit

What It Does

Out of the box, the plugin:

  • resolves c/* component imports from force-app/main/default/lwc
  • resolves lightning/* modules from project mocks or @salesforce/sfdx-lwc-jest stubs
  • provides virtual shims for @salesforce/* imports such as apex, schema, user, i18n, resourceUrl, and message channels
  • compiles LWC source with @lwc/compiler
  • generates a managed Vitest setup file automatically
  • enables jsdom, globals, coverage defaults, and LWC test file discovery
  • exposes jest as vi compatibility for existing tests that still use jest.mock() and jest.fn()

Install

pnpm add -D vitest @vitest/coverage-v8 @corekraft/vitest-plugin-lwc

If your project already uses @salesforce/sfdx-lwc-jest, keep it installed. The plugin reuses its Lightning stubs.

Existing Jest-Style LWC Tests

This plugin is designed to help projects move from sfdx-lwc-jest to Vitest with minimal churn.

Existing test suites can continue to use patterns like:

  • jest.mock(...)
  • jest.fn(...)
  • jest.requireActual(...)

The plugin rewrites those test helpers to Vitest-compatible behavior during transform.

Optional Extras

If these packages exist in the project, the generated setup file will use them automatically:

  • jest-canvas-mock
  • @sa11y/preset-rules
  • @sa11y/matcher

That means you can add them only when your test suite needs them.

Notes

  • This plugin expects a Salesforce DX project with sfdx-project.json.
  • The default test include pattern is **/lwc/**/*.test.js.
  • The default test environment is jsdom.
  • The plugin writes a managed setup file under .vitest-plugin-lwc/.

Example

The fixtures in this repository show the intended setup shape: