Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
dcb65a1
feat: open html trace reports
hi-ogawa Sep 3, 2026
676d424
refactor: scope trace report to run
hi-ogawa Sep 3, 2026
9f2da35
refactor: derive trace report path
hi-ogawa Sep 3, 2026
9443c7a
refactor: load worker config over rpc
hi-ogawa Sep 3, 2026
9acf87f
fix: preserve trace report hash route
hi-ogawa Sep 3, 2026
bc3245d
refactor: pass worker config on ready
hi-ogawa Sep 4, 2026
edb4c25
fix: scope trace report menu
hi-ogawa Sep 4, 2026
b150548
refactor: require worker config
hi-ogawa Sep 4, 2026
5b01323
refactor: group worker config metadata
hi-ogawa Sep 4, 2026
6030d5f
refactor: group worker config metadata
hi-ogawa Sep 4, 2026
4ec76e2
refactor: stack trace report on config metadata
hi-ogawa Sep 4, 2026
4ec0d4f
refactor: resolve html report path in worker
hi-ogawa Sep 4, 2026
714c7c4
refactor: align worker config declaration
hi-ogawa Sep 4, 2026
7763dfe
nit
hi-ogawa Sep 4, 2026
7bfb0d5
refactor: rely on trace command context
hi-ogawa Sep 4, 2026
b44eee6
docs: clarify browser fallback
hi-ogawa Sep 4, 2026
a8505cd
refactor: traverse trace tasks with queue
hi-ogawa Sep 4, 2026
3b661b3
refactor: scope trace queue per file
hi-ogawa Sep 4, 2026
ebfdf8c
docs: link trace report conventions
hi-ogawa Sep 4, 2026
ad81423
types: narrow trace artifact task
hi-ogawa Sep 4, 2026
2c9cd1b
docs: explain artifact type compatibility
hi-ogawa Sep 4, 2026
5b8f5fa
docs: explain trace action context
hi-ogawa Sep 4, 2026
8a572ad
test: add Vitest 5 browser sample
hi-ogawa Sep 4, 2026
d0556d5
feat: add trace report gutter action
hi-ogawa Sep 4, 2026
a80bb54
test: pin trace sample to Vitest RC
hi-ogawa Sep 4, 2026
82b7d29
test: align browser sample dependencies
hi-ogawa Sep 4, 2026
138f817
nit
hi-ogawa Sep 4, 2026
5db3fb4
refactor: align trace view naming
hi-ogawa Sep 4, 2026
42fccae
refactor: name trace view manager instances
hi-ogawa Sep 4, 2026
89e5229
refactor: name worker ready metadata
hi-ogawa Sep 4, 2026
84387c9
Merge branch 'refactor/worker-config-metadata' into trace-report-preview
hi-ogawa Sep 4, 2026
a1b7ee5
test: use stable Vitest 5 sample
hi-ogawa Sep 4, 2026
03ca883
fix: align worker Vite dependency
hi-ogawa Sep 4, 2026
6aec858
Merge main into trace-report-preview
hi-ogawa Sep 7, 2026
f496bc9
docs: document Trace View workflow
hi-ogawa Sep 7, 2026
740f3a7
docs: position Trace View section
hi-ogawa Sep 7, 2026
e18ff8d
docs: use Markdown trace image
hi-ogawa Sep 7, 2026
199efe5
docs: store Trace View screenshot
hi-ogawa Sep 7, 2026
82d0132
docs: preserve default reporters
hi-ogawa Sep 7, 2026
4c36cde
nit
hi-ogawa Sep 7, 2026
ee48e92
feat: open trace view in extension managed webview (#819)
hi-ogawa Sep 8, 2026
fa20f30
refactor: simplify trace report loading
hi-ogawa Sep 9, 2026
1cd14cc
chore: remove worker direct Vite dependency
hi-ogawa Sep 9, 2026
c3c8516
docs: outline trace panel behavior
hi-ogawa Sep 9, 2026
b18bc71
docs: explain trace view state lifecycle
hi-ogawa Sep 9, 2026
ee9b173
docs: clarify trace selection preservation
hi-ogawa Sep 9, 2026
87d64fd
docs: note trace reloads from external runs
hi-ogawa Sep 9, 2026
0d19012
refactor: name trace report entries explicitly
hi-ogawa Sep 9, 2026
4584397
docs: combine trace reload explanation
hi-ogawa Sep 9, 2026
6a23c92
docs: explain how trace selection survives reloads
hi-ogawa Sep 9, 2026
5d84924
docs: trim trace panel lifecycle comment
hi-ogawa Sep 9, 2026
a25c89f
test: smoke test opening trace view
hi-ogawa Sep 9, 2026
21066d7
nit
hi-ogawa Sep 9, 2026
2442bf0
feat: open trace view from command palette
hi-ogawa Sep 9, 2026
cc3e203
fix: load worker vitest config types
hi-ogawa Sep 9, 2026
e0a92c9
fix: align worker Vite dependency
hi-ogawa Sep 9, 2026
fe4e388
revert: open trace view from command palette
hi-ogawa Sep 9, 2026
450d813
test: explain custom menu setting
hi-ogawa Sep 9, 2026
74070c6
test: describe trace view smoke steps
hi-ogawa Sep 9, 2026
259b282
test: align trace test item selector
hi-ogawa Sep 9, 2026
42690a9
test: align Playwright and install Chromium in CI
hi-ogawa Sep 9, 2026
4966f3d
test: allow 15 seconds for trace results
hi-ogawa Sep 9, 2026
d96eedc
refactor: remove trace view revision tracking
hi-ogawa Sep 9, 2026
d0765e5
fix: allow external trace snapshot resources
hi-ogawa Sep 9, 2026
cde760c
fix: follow vscode theme in trace view
hi-ogawa Sep 9, 2026
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
deno-version: v2.x

- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install chromium
- run: pnpm build

- name: test
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ test-results
.yarn
.pnp.*
samples/**/coverage
samples/**/.vitest
tests-logs-*
*.tsbuildinfo
*.tsbuildinfo
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension Browser V5 Sample",
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/samples/browser-v5"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension Continuous Sample",
"type": "extensionHost",
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- **Coverage** support
- **Inline console.log display**: Console logs appear inline in the editor next to the code that produced them
- **Imports duration**: Displays the execution time for each import during continuous test runs.
- **Trace View**: Opens recorded Vitest 5 browser interactions for a selected test.

## Requirements

Expand Down Expand Up @@ -134,6 +135,28 @@ If you hover over it, you can get a more detailed diagnostic.

You can disable this feature by turning off `vitest.showImportsDuration`.

### Trace View

With Vitest 5, the extension can open recorded browser interactions for a selected test in [Vitest Trace View](https://vitest.dev/guide/browser/trace-view.html). Enable Trace View and the HTML reporter in your existing Browser Mode configuration:

```ts
import { configDefaults, defineConfig } from 'vitest/config'

export default defineConfig({
test: {
reporters: [...configDefaults.reporters, 'html'],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In general I don't like asking the user to update their configs since we can set any config we like when initiating Vitest, but I think it's fine for the initial version.

browser: {
// Your existing Browser Mode configuration
traceView: true,
},
},
})
```

After running a browser test through the extension, right-click the test in the Testing view or its editor gutter icon and select **Open Trace View**. The extension opens the trace view of the selected test from the generated HTML report in an editor tab.

![Vitest Trace View open in Visual Studio Code](./img/trace-view.png)

## FAQs (Frequently Asked Questions)

### How can I use it in monorepo?
Expand Down
Binary file added img/trace-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"tsdown": "catalog:",
"tsx": "catalog:",
"typescript": "catalog:",
"vite": "catalog:latest",
"vitest": "catalog:latest",
"which": "catalog:",
"ws": "catalog:"
Expand Down Expand Up @@ -121,6 +122,11 @@
"command": "vitest.openOutput",
"category": "Vitest"
},
{
"title": "Open Trace View",
"command": "vitest.openTraceView",
"category": "Vitest"
},
{
"title": "Show Shell Terminal",
"command": "vitest.showShellTerminal",
Expand Down Expand Up @@ -189,6 +195,10 @@
}
],
"commandPalette": [
{
"command": "vitest.openTraceView",
"when": "false"
},
{
"command": "vitest.toggleContinuousRun",
"when": "false"
Expand All @@ -203,6 +213,11 @@
}
],
"testing/item/context": [
{
"command": "vitest.openTraceView",
"when": "controllerId == 'vitest' && testId in vitest.traceViewTests",
"group": "vitest"
},
{
"command": "vitest.updateSnapshot",
"when": "controllerId == 'vitest'"
Expand All @@ -213,6 +228,11 @@
}
],
"testing/item/gutter": [
{
"command": "vitest.openTraceView",
"when": "controllerId == 'vitest' && testId in vitest.traceViewTests",
"group": "vitest"
},
{
"command": "vitest.updateSnapshot",
"when": "controllerId == 'vitest'"
Expand Down
4 changes: 4 additions & 0 deletions packages/extension/src/apiProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export class VitestProjectConfig {
return usesJestTestNamePattern(this.pkg)
}

get htmlReportPath() {
return this.metadata.htmlReportPath
}

get package() {
return this.pkg
}
Expand Down
9 changes: 9 additions & 0 deletions packages/extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ExtensionTerminalProcess } from './spawn/terminal'
import { ExtensionState } from './state'
import { TagsManager } from './tagsManager'
import { TestTree } from './testTree'
import { TraceViewManager } from './traceView'
import { getTestData, TestFile } from './testTreeData'
import { debounce, showVitestError } from './utils'
import './polyfills'
Expand Down Expand Up @@ -52,6 +53,7 @@ class VitestExtension {
private debugManager: DebugManager
private schemaProvider: TransformSchemaProvider
private importsBreakdownProvider: ImportsBreakdownProvider
private traceViewManager = new TraceViewManager()

/** @internal */
_debugDisposable: vscode.Disposable | undefined
Expand Down Expand Up @@ -106,6 +108,7 @@ class VitestExtension {
private async _defineTestProfiles(showWarning: boolean, cancelToken?: vscode.CancellationToken) {
this.importsBreakdownProvider.clear()
this.testTree.reset([])
this.traceViewManager.clear()
this.runQueues.forEach((q) => q.dispose())
this.runQueues.clear()

Expand Down Expand Up @@ -222,6 +225,7 @@ class VitestExtension {
vitest,
this.diagnostic,
this.importsBreakdownProvider,
this.traceViewManager,
)
const runQueueId = `${vitest.id}:run`
this.runQueues.set(runQueueId, runQueue)
Expand Down Expand Up @@ -284,6 +288,7 @@ class VitestExtension {
vitest,
this.diagnostic,
this.importsBreakdownProvider,
this.traceViewManager,
)
const coverageQueueId = `${vitest.id}:coverage`
this.runQueues.set(coverageQueueId, coverageQueue)
Expand Down Expand Up @@ -342,6 +347,9 @@ class VitestExtension {
vscode.commands.registerCommand('vitest.openOutput', () => {
log.openOutput()
}),
vscode.commands.registerCommand('vitest.openTraceView', (testItem: vscode.TestItem) =>
this.traceViewManager.open(testItem),
),
vscode.commands.registerCommand('vitest.runRelatedTests', async (uri?: vscode.Uri) => {
const currentUri = uri || vscode.window.activeTextEditor?.document.uri
if (!currentUri) {
Expand Down Expand Up @@ -638,6 +646,7 @@ class VitestExtension {
this.testController.dispose()
this.schemaProvider.dispose()
this.importsBreakdownProvider.dispose()
this.traceViewManager.dispose()
this.runProfiles.forEach((p) => p.dispose())
this.runProfiles.clear()
this.disposables.forEach((d) => d.dispose())
Expand Down
4 changes: 4 additions & 0 deletions packages/extension/src/runQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { RunHandle } from './apiProcess'
import type { ExtensionDiagnostic } from './diagnostic'
import type { ImportsBreakdownProvider } from './importsBreakdownProvider'
import type { TestTree } from './testTree'
import type { TraceViewManager } from './traceView'
import { VitestProcessAPI } from './apiProcess'
import { log } from './log'
import { ContinuousTestRunner, TestRunner } from './runner'
Expand Down Expand Up @@ -33,6 +34,7 @@ export class RunQueue {
private readonly api: VitestProcessAPI,
private readonly diagnostic: ExtensionDiagnostic | undefined,
private readonly importsBreakdown: ImportsBreakdownProvider,
private readonly traceViewManager: TraceViewManager,
) {}

public isContinuousTestItem(testItem: vscode.TestItem): boolean {
Expand Down Expand Up @@ -205,6 +207,7 @@ export class RunQueue {
api || this.api,
this.diagnostic,
this.importsBreakdown,
this.traceViewManager,
)
}

Expand All @@ -216,6 +219,7 @@ export class RunQueue {
this.api,
this.diagnostic,
this.importsBreakdown,
this.traceViewManager,
this.testRunProfile,
this.continuousRequests,
)
Expand Down
9 changes: 8 additions & 1 deletion packages/extension/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { RunHandle, VitestProcessAPI } from './apiProcess'
import type { ExtensionDiagnostic } from './diagnostic'
import type { ImportsBreakdownProvider } from './importsBreakdownProvider'
import type { TestTree } from './testTree'
import type { TraceViewManager } from './traceView'
import crypto from 'node:crypto'
import path from 'node:path'
import { stripVTControlCharacters } from 'node:util'
Expand Down Expand Up @@ -40,6 +41,7 @@ export class TestRunner extends vscode.Disposable {
protected readonly api: VitestProcessAPI,
protected readonly diagnostic: ExtensionDiagnostic | undefined,
protected readonly importsBreakdown: ImportsBreakdownProvider,
protected readonly traceViewManager?: TraceViewManager,
) {
super(() => {
log.verbose?.('Disposing test runner')
Expand Down Expand Up @@ -110,6 +112,10 @@ export class TestRunner extends vscode.Disposable {
})

handle.handlers.onTestRunEnd(async (files, unhandledError, collecting, coverage) => {
const htmlReportPath = this.api.config.htmlReportPath
if (!collecting && htmlReportPath) {
await this.traceViewManager?.update(this.api.id, htmlReportPath, files, this.tree)
}
const testRun = this.testRun

if (!testRun) {
Expand Down Expand Up @@ -369,10 +375,11 @@ export class ContinuousTestRunner extends TestRunner {
api: VitestProcessAPI,
diagnostic: ExtensionDiagnostic | undefined,
importsBreakdown: ImportsBreakdownProvider,
traceViewManager: TraceViewManager,
private readonly testRunProfile: vscode.TestRunProfile,
private readonly continuousRequests: Set<vscode.TestRunRequest>,
) {
super(handle, controller, tree, api, diagnostic, importsBreakdown)
super(handle, controller, tree, api, diagnostic, importsBreakdown, traceViewManager)
handle.handlers.onTestRunStart((files) => {
this.startTestRun(files)
log.verbose?.(
Expand Down
Loading
Loading