Skip to content
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
5 changes: 3 additions & 2 deletions packages/ui/client/composables/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ watch(
ws.addEventListener('open', async () => {
status.value = 'OPEN'
client.state.filesMap.clear()
let [files, _config, errors] = await Promise.all([
let [files, _config, errors, projects] = await Promise.all([
client.rpc.getFiles(),
client.rpc.getConfig(),
client.rpc.getUnhandledErrors(),
client.rpc.getResolvedProjectNames(),
])
if (_config.standalone) {
const filenames = await client.rpc.getTestFiles()
Expand All @@ -166,7 +167,7 @@ watch(
return file
})
}
explorerTree.loadFiles(files)
explorerTree.loadFiles(files, projects)
client.state.collectFiles(files)
explorerTree.startRun()
unhandledErrors.value = (errors || []).map(parseError)
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/client/composables/client/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface HTMLReportMetadata {
paths: string[]
files: File[]
config: SerializedConfig
projects: string[]
moduleGraph: Record<string, Record<string, ModuleGraphData>>
unhandledErrors: unknown[]
// filename -> source
Expand Down Expand Up @@ -47,6 +48,9 @@ export function createStaticClient(): VitestClient {
getConfig: () => {
return metadata.config
},
getResolvedProjectNames: () => {
return metadata.projects
},
getModuleGraph: async (projectName, id) => {
return metadata.moduleGraph[projectName]?.[id]
},
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/client/composables/explorer/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class ExplorerTree {
private rafCollector: ReturnType<typeof useRafFn>
private resumeEndRunId: ReturnType<typeof setTimeout> | undefined
constructor(
public projects: string[] = [],
private onTaskUpdateCalled: boolean = false,
private resumeEndTimeout = 500,
public root = <RootTreeNode>{
Expand Down Expand Up @@ -53,7 +54,8 @@ export class ExplorerTree {
this.rafCollector = useRafFn(this.runCollect.bind(this), { fpsLimit: 10, immediate: false })
}

loadFiles(remoteFiles: File[]) {
loadFiles(remoteFiles: File[], projects: string[]) {
this.projects.splice(0, this.projects.length, ...projects)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will require some changes when exposing the data for the filter selector, should be fixed in #7201 once merged

runLoadFiles(
remoteFiles,
true,
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/node/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface HTMLReportData {
paths: string[]
files: File[]
config: SerializedConfig
projects: string[]
moduleGraph: Record<string, Record<string, ModuleGraphData>>
unhandledErrors: unknown[]
// filename -> source
Expand Down Expand Up @@ -65,6 +66,7 @@ export default class HTMLReporter implements Reporter {
files: this.ctx.state.getFiles(),
config: this.ctx.getRootProject().serializedConfig,
unhandledErrors: this.ctx.state.getUnhandledErrors(),
projects: this.ctx.resolvedProjects.map(p => p.name),
moduleGraph: {},
sources: {},
}
Expand Down
3 changes: 3 additions & 0 deletions packages/vitest/src/api/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export function setup(ctx: Vitest, _server?: ViteDevServer) {
getConfig() {
return ctx.getRootProject().serializedConfig
},
getResolvedProjectNames(): string[] {
return ctx.resolvedProjects.map(p => p.name)
},
async getTransformResult(projectName: string, id, browser = false) {
const project = ctx.getProjectByName(projectName)
const result: TransformResultWithSource | null | undefined = browser
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface WebSocketHandlers {
getTestFiles: () => Promise<SerializedTestSpecification[]>
getPaths: () => string[]
getConfig: () => SerializedConfig
getResolvedProjectNames: () => string[]
getModuleGraph: (
projectName: string,
id: string,
Expand Down
6 changes: 6 additions & 0 deletions test/reporters/tests/__snapshots__/html.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ exports[`html reporter > resolves to "failing" status for test file "json-fail"
"paths": [
"<rootDir>/test/reporters/fixtures/json-fail.test.ts",
],
"projects": [
"",
],
"sources": {
"<rootDir>/test/reporters/fixtures/json-fail.test.ts": "import { expect, test } from 'vitest'

Expand Down Expand Up @@ -195,6 +198,9 @@ exports[`html reporter > resolves to "passing" status for test file "all-passing
"paths": [
"<rootDir>/test/reporters/fixtures/all-passing-or-skipped.test.ts",
],
"projects": [
"",
],
"sources": {
"<rootDir>/test/reporters/fixtures/all-passing-or-skipped.test.ts": "import { expect, test } from 'vitest'

Expand Down