Skip to content

Commit

Permalink
next: testing library setup (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Apr 21, 2024
1 parent 0f05c47 commit b0b2359
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/bits-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/svelte": "^4.2.2",
"@testing-library/svelte": "^5.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/jest-axe": "^3.5.9",
"@types/node": "^20.12.2",
Expand Down
17 changes: 14 additions & 3 deletions packages/bits-ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import process from "node:process";
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vitest/config";
import type { Plugin } from "vite";

export default defineConfig({
plugins: [sveltekit()],
const vitestBrowserConditionPlugin: Plugin = {
name: "vite-plugin-vitest-browser-condition",
//@ts-expect-error - idk
config({ resolve }: { resolve: { conditions: string[] } }) {
if (process.env.VITEST) {
resolve.conditions.unshift("browser");
}
},
};

export default defineConfig({
plugins: [vitestBrowserConditionPlugin, sveltekit()],
test: {
include: ["src/**/*.{test,spec}.{js,ts}"],
// jest like globals
Expand All @@ -14,7 +25,7 @@ export default defineConfig({
// Add @testing-library/jest-dom's matchers & mocks of SvelteKit modules
setupFiles: ["./other/setupTest.ts"],
coverage: {
exclude: ["setupTest.ts"],
exclude: ["./other/setupTest.ts"],
},
retry: 3,
},
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b0b2359

Please sign in to comment.