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 🙏

© 2024 – Pkg Stats / Ryan Hefner

vitest-dom

v0.1.1

Published

Custom Vitest matchers to test the state of the DOM, forked from jest-dom.

Downloads

203,508

Readme


version MIT License

Watch on GitHub

This library is a fork of @testing-library/jest-dom. It shares that library's implementation and API. It is intended to make it easier to include its matchers without clashes between Vitest and Jest's environment or types.

See the README for the original package for usage details.

Installation

This module should be installed as one of your project's devDependencies:

# with npm
npm install --save-dev vitest-dom
# yarn
yarn add --dev vitest-dom
# pnpm
pnpm add --dev vitest-dom

Usage

Import the matchers from vitest-dom/matchers once (perferably in your tests setup file), then pass them to Vitest's expect.extend method:

// vitest-setup.js
import * as matchers from "vitest-dom/matchers";
import { expect } from "vitest";
expect.extend(matchers);

// or:
import "vitest-dom/extend-expect";

// In vitest.config.js, add the following
export default defineConfig({
  test: {
    setupFiles: ["vitest-setup.js"],
  },
});

With TypeScript

If you're using TypeScript, make sure your setup file has a .ts extension to include the necessary types.

If you import from vitest-dom/extend-expect to run expect.extend for you, you will get TypeScript support automatically.

// vitest-setup.ts
import "vitest-dom/extend-expect";

If you want to run extend.expect yourself, you will need to include the type defintions either with a /// <reference /> directive or including the type in your compilerOptions:

  1. In your test file via a reference directive:
    /// <reference types="vitest-dom/extend-expect" />
  2. In your tsconfig.json via the types compiler option:
    {
      "compilerOptions": {
        "types": ["vitest-dom/extend-expect"]
      }
    }