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

Overview

vitest-dom

Custom Vitest matchers to test the state of the DOM


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);

// 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 is a .ts and not a .js to include the necessary types. Importing from vitest-dom/extend-expect will add the matchers to Vitest's expect types.

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

You will also need to include your setup file in your tsconfig.json if you haven't already:

  // In tsconfig.json
  "include": [
    // ...
    "./vitest-setup.ts"
  ],
You might also like...

Remix + Cloudflare Workers + Wrangler2 + Tailwind + ESLint + Prettier + Vitest + Playwright

Welcome to Remix! Remix Docs Development You will be running two processes during development: The Miniflare server (miniflare is a local environment

Dec 19, 2022

🚀 A boilerplate with generic configurations to a Nextjs project with bun, vitest, cicd and etc

👕 Next.JS Template with Linter 🔨 Tools: NextJS Typescript ESLint (Code Pattern) Prettier (Formatter) Husky (Pre-commit) Vitest (Unit/Integration Tes

Dec 18, 2022

🔥 TypeScript type assertion plugin for vitest

🔥 TypeScript type assertion plugin for vitest

TypeScript type assertion plugin for vitest. 📌 This plugin is in alpha version, and will probably stay that way for a long time, it lacks tests (a bi

Nov 23, 2022

Nuxt3 template with Windicss + Pinia + Vitest + Playwright

Nuxt3 template with Windicss + Pinia + Vitest + Playwright

Nuxt 3 Template Nuxt 3 template repository Look at the nuxt 3 documentation to learn more. Used Technologies Usage Setup Make sure to install the depe

Dec 14, 2022

A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

Live Demo · Twitter A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Pris

Oct 31, 2022

Nuxt.js 3 x Histoire x Vitest x VitePress x Turbo (pnpm)

Turborepo nuxt starter This is a monorepo with Nuxt, Histoire, Vitest & VitePress as a starter for any project that can be easily extended. You can al

Dec 19, 2022

Jester is a test-generation tool to create integration test code.

Jester is a test-generation tool to create integration test code.

Code Generator for Integration Tests Introduction Welcome to Jester: An easy-to-use web application that helps you create and implement integration te

Dec 12, 2022

logseq custom.js and custom.css utilities : resize query table columns, hide namespaces...

logseq custom.js and custom.css utilities : resize query table columns, hide namespaces...

logseq-custom-files custom.js and custom.css utilities for Logseq. current version v20220331 query table view : add handles on the query table headers

Dec 7, 2022

This experimental library patches the global custom elements registry to allow re-defining or reload a custom element.

Redefine Custom Elements This experimental library patches the global custom elements registry to allow re-defining a custom element. Based on the spe

Dec 11, 2022
Owner
Chance Strickland
Software Engineer @remix-run
Chance Strickland
Kuldeep 2 Jun 21, 2022
A jest reporter that shows test running stats using the HUD macOS app.

jest-hud-reporter A jest reporter that shows test running stats using the HUD macOS app. hud-jest.mp4 Installation This package is available as a NPM

Nando Vieira 4 Feb 26, 2022
In this project I write the test for several functions and used the TDD with Jest and JavaScript.

JavaScript-Testing-with-Jest npm init -y npm install --save-dev jest Once installed, you should see it in already created Json file Change Jest Script

Ben Kiboma Omayio 2 Jun 11, 2022
This work is an overnight with 84436, an overlay code forked from Osu! community but for ``flag of Vietnam`` in r/place 2022

flag-of-vietnam-rplace2022 This work is a overnight with 84436, an overlay code forked from Osu! community but for flag of Vietnam Installation Xài Ta

Đoàn Đình Toàn 10 Nov 2, 2022
Framework for interacting with instagrams private api in a usable manner (forked from andre's work and improved and fixed)

node-ig-framework Framework for interacting with instagrams private api in a usable manner (forked from andre's work and improved and fixed) Installat

nine ecksen 3 Dec 31, 2022
Macarena finance is a simple UI for Yearn Finance, made to be forked!

Macarena Finance Macarena finance is a simple UI for Yearn Finance, made to be forked! Running your own instance of Yearn makes you eligible to earn f

yearn 17 Oct 1, 2022
📦 🍣 Zero-config JS bundler for ESM, CommonJS, and .d.ts outputs. (Forked from pkgroll)

?? ?? puild (A fork of pkgroll) Write your code in ESM & TypeScript and bundle it to get ESM, CommonJS, and type declaration outputs with a single com

ʀᴀʏ 6 Sep 6, 2022
Forked from hayes0724/shopify-packer Modern development tool for Shopify using Webpack 5. Easy to extend and customize, zero build config, compatible with Slate and existing websites.

Shopify Packer Modern development tool for Shopify using Webpack 5. Easy to extend and customize, zero build config, comes with starter themes and com

Web & Mobile | eCommerce | Full-Stack Developer 4 Nov 24, 2022
forked from https://github.com/ecomfe/fontmin

@sctg/fontminify (just a minimal change to original) Minify font seamlessly Original homepage English 简体中文 繁體中文 日本語 한국어 Install $ npm install --save @

Association High Can Fly 2 Oct 12, 2022
Vitest for coc.nvim

coc-vitest Vitest for coc.nvim Install vim-plug: Plug 'yaegassy/coc-vitest', {'do': 'yarn install --frozen-lockfile'} CocInstall: Not supported at thi

yaegassy 8 Sep 4, 2022