Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: implement vitest workspace #2299

Merged
merged 8 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/tough-peas-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"pretest": "turbo run pretest",
"depcheck": "knip --dependencies --tags=-knipignore",
"knip:fix": "knip --fix",
"test": "vitest --run --coverage --config vite.node.config.mts $(scripts/tests-find.sh --node)",
"test:filter": "vitest --run --coverage --config vite.node.config.mts",
"test": "vitest --run --coverage --config vitest.node.config.mts $(scripts/tests-find.sh --node)",
"test:filter": "vitest --run --coverage --config vitest.node.config.mts",
"test:coverage-merge": "tsx ./scripts/tests-coverage-merge.ts",
"test:coverage-diff": "tsx ./scripts/tests-coverage-diff.ts",
"test:watch": "vitest --watch --config vite.node.config.mts $(scripts/tests-find.sh --node)",
"test:watch": "vitest --watch --config vitest.node.config.mts $(scripts/tests-find.sh --node)",
"test:validate": "./scripts/tests-validate.sh",
"test:browser": "vitest --run --coverage --config vite.browser.config.mts $(scripts/tests-find.sh --browser)",
"test:browser:filter": "vitest --run --coverage --config vite.browser.config.mts",
"test:e2e": "vitest --run --config vite.node.config.mts $(scripts/tests-find.sh --e2e)",
"test:browser": "vitest --run --coverage --config vitest.browser.config.mts $(scripts/tests-find.sh --browser)",
"test:browser:filter": "vitest --run --coverage --config vitest.browser.config.mts",
"test:e2e": "vitest --run --config vitest.node.config.mts $(scripts/tests-find.sh --e2e)",
"lint": "run-s lint:check prettier:check",
"lint:check": "eslint . --ext .ts --max-warnings 0",
"lint:fix": "pnpm lint:check --fix",
Expand Down
14 changes: 0 additions & 14 deletions vite.node.config.mts

This file was deleted.

6 changes: 3 additions & 3 deletions vite.browser.config.mts → vitest.browser.config.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { nodePolyfills } from "vite-plugin-node-polyfills";
import { mergeConfig } from "vitest/config";
import type { UserConfig } from "vitest/config";
import { mergeConfig, defineProject } from "vitest/config";

import baseConfig from "./vite.base.config.mts";
import sharedConfig from "./vitest.shared.config.mts";

const config: UserConfig = {
plugins: [
Expand Down Expand Up @@ -42,4 +42,4 @@ const config: UserConfig = {
},
};

export default mergeConfig(baseConfig, config);
export default mergeConfig(sharedConfig, defineProject(config));
24 changes: 24 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
coverage: {
enabled: true,
provider: 'istanbul',
reporter: ['json', 'text', 'html'],
include: ['packages', 'internal', 'apps'],
exclude: [
'**/*.js',
'**/node_modules/**',
'**/dist/**',
'**/test/**',
'**/*.test.ts',
'**/*.d.ts',
'**/bin.ts',
'packages/fuel-gauge/**',
'apps/demo-*',
'apps/docs',
],
},
},
});
File renamed without changes.
14 changes: 14 additions & 0 deletions vitest.node.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { UserConfig } from "vitest/config";
import { mergeConfig, defineProject } from "vitest/config";

import sharedConfig from "./vitest.shared.config.mts";

const config: UserConfig = {
test: {
coverage: {
reportsDirectory: "coverage/environments/node",
},
},
};

export default mergeConfig(sharedConfig, defineProject(config));
20 changes: 10 additions & 10 deletions vite.base.config.mts → vitest.shared.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ export default defineConfig({
}),
],
test: {
exclude: [
"**/node_modules/**",
"**/dist/**",
"/apps/demo-nextjs",
"/apps/demo-react-cra",
"/apps/demo-react-vite",
],
globals: true,
setupFiles: ["./vite.env.ts"],
env: loadEnv(mode, process.cwd(), ""),
coverage: {
enabled: true,
provider: "istanbul",
Expand All @@ -39,6 +29,16 @@ export default defineConfig({
"apps/docs",
],
},
exclude: [
"**/node_modules/**",
"**/dist/**",
"/apps/demo-nextjs",
"/apps/demo-react-cra",
"/apps/demo-react-vite",
],
globals: true,
setupFiles: ["./vitest.env.ts"],
env: loadEnv(mode, process.cwd(), ""),
poolOptions: {
threads: {
minThreads: 1,
Expand Down
3 changes: 3 additions & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineWorkspace } from 'vitest/config';

export default defineWorkspace(['./vitest.node.config.mts', './vitest.browser.config.mts']);
Loading