From 1b781e463b2dbb52cb8d5a1ceef0e14122665a28 Mon Sep 17 00:00:00 2001 From: Serdar Sayin Date: Fri, 15 Sep 2023 14:27:06 +0200 Subject: [PATCH] test(react-media): add test config --- packages/react-media/package.json | 2 +- packages/react-media/test/setup.ts | 7 +++++++ packages/react-media/vitest.config.ts | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/react-media/test/setup.ts create mode 100644 packages/react-media/vitest.config.ts 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"], + }, + }, +});