Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit

Permalink
chore: use vitest workspaces (trpc#5461)
Browse files Browse the repository at this point in the history
* use vitewt workspaces

* sync lock

* fix coverage?

* maybe CI bust?

* oh yeet

* test v3

* change some scripts

* rev settings.json
  • Loading branch information
juliusmarminge authored Mar 4, 2024
1 parent 0a3c261 commit 73447f7
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 166 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ jobs:
fetch-depth: 0
- uses: ./.github/setup

- name: Test
run: pnpm turbo --filter tests test-ci
- name: Build tRPC, then test
run: pnpm turbo --filter "@trpc/*" build
- run: pnpm test-ci

- uses: codecov/codecov-action@v4
with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
directory: ./packages
- uses: codecov/codecov-action@v3
# with:
# # token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
# directory: .

e2e:
name: 'E2E-tests'
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal-react/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@vitejs/plugin-react": "^3.1.0",
"eslint": "^8.56.0",
"typescript": "^5.3.3",
"vite": "^5.0.12"
"vite": "^5.1.0"
}
}
2 changes: 1 addition & 1 deletion examples/next-prisma-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"tailwindcss": "^3.3.0",
"tsx": "^4.0.0",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite": "^5.1.0",
"vitest": "^1.2.2"
},
"publishConfig": {
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"build-www": "turbo --filter www build",
"dev": "turbo --filter=\"@trpc/*\" dev",
"dev-www": "turbo --filter www dev",
"test": "FORCE_COLOR=1 turbo --filter \"@trpc/tests\" test -- --retry=1",
"test-watch": "cd packages/tests && pnpm test-watch",
"test": "turbo codegen-tests && conc -c \"green,blue\" \"vitest run\" \"pnpm -F tests test-run:tsc\"",
"test-ci": "turbo codegen-tests && conc \"CI=true vitest run --coverage\" \"pnpm -F tests test-run:tsc\"",
"test-watch": "vitest --typecheck",
"ts-watch": "turbo run ts-watch",
"vitest": "cd packages/tests && pnpm vitest",
"lint": "turbo lint",
"lint-fix": "turbo lint -- --fix && manypkg fix && pnpm format-fix",
"format": "prettier \"**/*\" --ignore-unknown",
Expand Down Expand Up @@ -53,7 +53,11 @@
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@vitest/coverage-istanbul": "^1.2.2",
"@vitest/ui": "^1.2.2",
"concurrently": "^8.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand All @@ -77,7 +81,9 @@
"tsx": "^4.0.0",
"turbo": "^1.10.2",
"typescript": "^5.3.3",
"vite": "^5.1.0",
"vitest": "^1.2.2",
"vitest-environment-miniflare": "^2.14.1",
"zod": "^3.0.0"
},
"pnpm": {
Expand Down
4 changes: 1 addition & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"@trpc/server": "^10.45.1"
},
"devDependencies": {
"@testing-library/dom": "^9.0.0",
"@trpc/server": "^10.45.1",
"@types/isomorphic-fetch": "^0.0.39",
"@types/node": "^20.10.0",
Expand All @@ -89,8 +88,7 @@
"node-fetch": "^3.3.0",
"rollup": "^4.9.5",
"tsx": "^4.0.0",
"undici": "^6.0.1",
"vitest": "^1.2.2"
"undici": "^6.0.1"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 1 addition & 0 deletions packages/client/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../vitest.config';
1 change: 1 addition & 0 deletions packages/next/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../vitest.config';
1 change: 1 addition & 0 deletions packages/react-query/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../vitest.config';
1 change: 0 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"tsx": "^4.0.0",
"typescript": "^5.3.3",
"valibot": "^0.29.0",
"vitest": "^1.2.2",
"ws": "^8.0.0",
"yup": "^1.0.0",
"zod": "^3.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/server/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../vitest.config';
11 changes: 0 additions & 11 deletions packages/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"codegen:bigBoi": "tsx ../../scripts/generateBigBoi.ts",
"codegen-tests": "run-p codegen:*",
"lint": "eslint --cache --ext .ts,.tsx --ignore-path ../../.gitignore .",
"test": "concurrently -P -c \"green,blue\" \"npm:test-run:vitest -- {@}\" npm:test-run:tsc",
"test-run:vitest": "vitest --run",
"test-run:tsc": "tsc --noEmit --pretty",
"test-watch": "vitest",
"test-ci": "concurrently \"CI=true vitest --coverage\" npm:test-run:tsc",
"test-ui": "vitest --ui",
"ts-watch": "tsc --watch"
},
"dependencies": {
Expand All @@ -29,11 +24,8 @@
"@trpc/server": "^10.45.1",
"@types/node": "^20.10.0",
"@typeschema/valibot": "^0.13.0",
"@vitest/coverage-istanbul": "^1.2.2",
"@vitest/ui": "^1.2.2",
"abort-controller": "^3.0.0",
"arktype": "1.0.14-alpha",
"concurrently": "^8.0.0",
"dataloader": "^2.2.2",
"devalue": "^4.0.0",
"eslint": "^8.56.0",
Expand All @@ -54,9 +46,6 @@
"tupleson": "0.23.1",
"typescript": "^5.3.3",
"valibot": "^0.29.0",
"vite": "^5.0.12",
"vitest": "^1.2.2",
"vitest-environment-miniflare": "^2.14.1",
"ws": "^8.0.0",
"yup": "^1.0.0",
"zod-form-data": "^2.0.1"
Expand Down
64 changes: 1 addition & 63 deletions packages/tests/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1 @@
import fs from 'fs';
import path from 'path';
import { defineConfig } from 'vitest/config';

const aliases: Record<string, string> = {};

const dirs = fs
.readdirSync(path.join(__dirname, '../'))
.filter((it) => it !== 'tests' && !it.startsWith('.'))
.filter((it) => fs.existsSync(path.join(__dirname, `../${it}/package.json`)));

for (const pkg of dirs.sort()) {
const pkgJson = path.join(__dirname, `/../${pkg}/package.json`);

const json = JSON.parse(fs.readFileSync(pkgJson, 'utf-8').toString());
const exports = json.exports;
for (const key of Object.keys(exports).sort()) {
if (key.includes('.json')) {
continue;
}
// trim first './'
const trimmed = key.slice(1);
aliases[`@trpc/${pkg}${trimmed}`] = path
.join(__dirname, `../${pkg}/src${key.slice(1)}`)
.replace(/\\/g, '/');
}
}

export default defineConfig({
root: '../',
clearScreen: false,
test: {
environment: 'jsdom',
globals: true,
snapshotFormat: {
printBasicPrototype: true,
},
setupFiles: ['./tests/setupTests.ts'],
coverage: {
provider: 'istanbul',
include: ['*/src/**/*.{ts,tsx,js,jsx}'],
exclude: ['**/deprecated/**'],
},
poolOptions: {
threads: {
useAtomics: !!process.env['CI'],
},
},
},
resolve: {
alias: {
...aliases,
'vitest-environment-miniflare': [
__dirname,
'node_modules/vitest-environment-miniflare',
].join('/'),
'@vitest/coverage-istanbul': [
__dirname,
'node_modules/@vitest/coverage-istanbul',
].join('/'),
},
},
});
export { default } from '../../vitest.config';
Loading

0 comments on commit 73447f7

Please sign in to comment.