Skip to content

Commit

Permalink
feat: use vitest workspace projects for our packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Apr 22, 2024
1 parent a00d69f commit 54de89b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 6 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@ownclouders/tsconfig": "workspace:*",
"@playwright/test": "1.39.0",
"@rollup/plugin-inject": "5.0.3",
"@types/glob": "8.1.0",
"@types/lodash-es": "4.17.7",
"@types/node": "16.18.30",
"@types/node-fetch": "2.6.10",
Expand All @@ -81,6 +82,7 @@
"eslint": "8.56.0",
"flush-promises": "1.0.2",
"git-repo-info": "2.1.1",
"glob": "10.3.12",
"happy-dom": "13.3.1",
"join-path": "1.1.1",
"jsdom": "^20.0.2",
Expand Down
42 changes: 40 additions & 2 deletions pnpm-lock.yaml

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

4 changes: 1 addition & 3 deletions tests/unit/config/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default defineConfig({
}
],
test: {
name: 'unit',
root,
globals: true,
environment: 'happy-dom',
Expand All @@ -35,8 +34,7 @@ export default defineConfig({
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'.pnpm-store/*',
'packages/design-system/tests/e2e/**',
'packages/design-system/docs/**'
'e2e/**'
],
alias: {
'vue-inline-svg': `${root}/tests/unit/stubs/empty.ts`,
Expand Down
17 changes: 16 additions & 1 deletion vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { defineWorkspace } from 'vitest/config'
import { globSync } from 'glob'

// set timezone for snapshot reproducibility on different machines
process.env.TZ = 'UTC'

export default defineWorkspace(['./tests/unit/config/vitest.config.ts'])
const pattern = './packages/*/tests'
const testDirs = [...globSync(pattern), './packages/design-system/src']

export default defineWorkspace(
testDirs.map((dir) => {
const name = dir.split('/')[1]
return {
extends: './tests/unit/config/vitest.config.ts',
test: {
name,
dir
}
}
})
)

0 comments on commit 54de89b

Please sign in to comment.