Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 9b9bd43

Browse files
authored
vitest: Fix workspace config wrt client/web/ (#58397)
It appears that the workspace configuration is somehow broken because it doesn't include any tests defined in `client/web/src/`. This can be tested by filtering for a test inside this subtree, for example pnpm exec vitest RepoRevisionSidebar vitest will error saying it didn't find any tests. The list of projects it prints also doesn't include `web`. I don't know what exactly it is that makes it exclude `client/web/` but with the simpler version in this PR `client/web/` will be included. I removed `client/web/dev/` from the list because it will be included by `client/web/` too and seems to "just work" even though it has it's own configuration file.
1 parent cb068f3 commit 9b9bd43

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

vitest.workspace.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { readFileSync, existsSync } from 'fs'
1+
import { readFileSync } from 'fs'
22
import path from 'path'
33

4-
import glob from 'glob'
54
import { load } from 'js-yaml'
6-
import { defineWorkspace } from 'vitest/config'
75

86
interface PnpmWorkspaceFile {
97
packages: string[]
108
}
11-
const workspaceFile = load(readFileSync(path.join(__dirname, 'pnpm-workspace.yaml'), 'utf8')) as PnpmWorkspaceFile
12-
workspaceFile.packages.push('client/web/dev') // is a tsconfig project but not a pnpm workspace package
13-
const projectRoots = workspaceFile.packages
14-
.flatMap(p => glob.sync(`${p}/`, { cwd: __dirname }))
15-
.map(p => p.replace(/\/$/, ''))
16-
.filter(dir => existsSync(path.join(dir, 'vitest.config.ts')))
179

18-
export default defineWorkspace(projectRoots)
10+
function fromPnpmWorkspaceFile(filePath: string): string[] {
11+
return (load(readFileSync(filePath, 'utf8')) as PnpmWorkspaceFile).packages.map(p => `${p}/vitest.config.ts`, {
12+
cwd: __dirname,
13+
})
14+
}
15+
16+
export default fromPnpmWorkspaceFile(path.join(__dirname, 'pnpm-workspace.yaml'))

0 commit comments

Comments
 (0)