diff --git a/packages/react-media/package.json b/packages/react-media/package.json index fd438f50..d224cbb8 100644 --- a/packages/react-media/package.json +++ b/packages/react-media/package.json @@ -16,7 +16,7 @@ "license": "MIT", "scripts": { "lint": "TIMING=1 eslint \"**/*.ts*\"", - "test": "echo \"No tests configured.\"", + "test": "vitest run --coverage", "build": "tsup index.ts --format esm,cjs --dts", "dev": "tsup index.ts --format esm,cjs --watch --external react" }, diff --git a/packages/react-media/test/setup.ts b/packages/react-media/test/setup.ts new file mode 100644 index 00000000..d6ab365e --- /dev/null +++ b/packages/react-media/test/setup.ts @@ -0,0 +1,7 @@ +import { cleanup } from "@testing-library/react"; +import { afterEach } from "vitest"; + +// Clears the JSDom after each "it" statement +afterEach(() => { + cleanup(); +}); diff --git a/packages/react-media/vitest.config.ts b/packages/react-media/vitest.config.ts new file mode 100644 index 00000000..ada25fd5 --- /dev/null +++ b/packages/react-media/vitest.config.ts @@ -0,0 +1,16 @@ +import react from "@vitejs/plugin-react"; +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + plugins: [react()], + test: { + environment: "jsdom", + setupFiles: "./test/setup.ts", + passWithNoTests: true, + coverage: { + provider: "v8", + reporter: ["text", "html", "clover", "json", "lcov"], + exclude: ["./test/setup.ts"], + }, + }, +});