Skip to content

Commit

Permalink
chore: show unhandled errors in html report
Browse files Browse the repository at this point in the history
  • Loading branch information
spiroka committed Oct 28, 2023
1 parent 7bc6598 commit 3263aa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/ui/client/composables/client/static.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BirpcReturn } from 'birpc'
import type { VitestClient } from '@vitest/ws-client'
import type { WebSocketHandlers } from 'vitest/src/api/types'
import type { WebSocketEvents, WebSocketHandlers } from 'vitest/src/api/types'
import { parse } from 'flatted'
import { decompressSync, strFromU8 } from 'fflate'
import type { File, ModuleGraphData, ResolvedConfig } from 'vitest/src/types'
Expand All @@ -11,6 +11,7 @@ interface HTMLReportMetadata {
files: File[]
config: ResolvedConfig
moduleGraph: Record<string, ModuleGraphData>
unhandledErrors: unknown[]
}

const noop: any = () => {}
Expand Down Expand Up @@ -42,6 +43,9 @@ export function createStaticClient(): VitestClient {
getModuleGraph: async (id) => {
return metadata.moduleGraph[id]
},
getUnhandledErrors: () => {
return metadata.unhandledErrors
},
getTransformResult: async (id) => {
return {
code: id,
Expand All @@ -66,10 +70,11 @@ export function createStaticClient(): VitestClient {
saveSnapshotFile: asyncNoop,
readTestFile: asyncNoop,
removeSnapshotFile: asyncNoop,
getUnhandledErrors: () => [],
onUnhandledError: noop,
saveTestFile: asyncNoop,
} as WebSocketHandlers

ctx.rpc = rpc as any as BirpcReturn<WebSocketHandlers>
ctx.rpc = rpc as any as BirpcReturn<WebSocketHandlers, WebSocketEvents>

let openPromise: Promise<void>

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 @@ -15,6 +15,7 @@ interface HTMLReportData {
files: File[]
config: ResolvedConfig
moduleGraph: Record<string, ModuleGraphData>
unhandledErrors: unknown[]
}

const distDir = resolve(fileURLToPath(import.meta.url), '../../dist')
Expand All @@ -34,6 +35,7 @@ export default class HTMLReporter implements Reporter {
paths: this.ctx.state.getPaths(),
files: this.ctx.state.getFiles(),
config: this.ctx.config,
unhandledErrors: this.ctx.state.getUnhandledErrors(),
moduleGraph: {},
}
await Promise.all(
Expand Down

0 comments on commit 3263aa8

Please sign in to comment.