npm.io
0.0.2 • Published 7 months ago

vitest-indexeddb

Licence
MIT
Version
0.0.2
Deps
1
Size
4 kB
Vulns
0
Weekly
0
Stars
2

vitest-indexeddb

Add a shim for indexeddb when testing with Vitest.

Installation

yarn add -D vitest-indexeddb
npm i -D vitest-indexeddb
pnpm i -D vitest-indexeddb

Usage

An example project can be found at /example for reference.

  1. Create a setup file
// ./setup/idbSetup.ts

import { setup } from "vitest-indexeddb";

setup();
  1. Include that setup file in your Vitest config.
// ./vite.config.ts

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    environment: "jsdom",
    setupFiles: ["./setup/idbSetup.ts"],
  },
});
  1. Run tests

Keywords