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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ test-results
.yarn
.pnp.*
samples/**/coverage
tests-logs-*
tests-logs-*
*.tsbuildinfo
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ These options are resolved relative to the [workspace file](https://code.visuals
- `vitest.maximumConfigs`: The maximum amount of configs that Vitest extension can load. If exceeded, the extension will show a warning suggesting to use a workspace config file. Default: `5`
- `vitest.logLevel`: How verbose should the logger be in the "Output" channel. Default: `info`
- `vitest.applyDiagnostic`: Show a squiggly line where the error was thrown. This also enables the error count in the File Tab. Default: `true`
- `vitest.showInlineConsoleLog`: Show console.log messages inline in the editor next to the code that produced them. When disabled, console logs will still appear in the test output but not inline. Default: `true`
- `vitest.experimentalStaticAstCollect`: uses AST parses to collect tests instead of running files and collecting them at runtime. Default: `true`

### Commands
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,20 @@
"vitest.applyDiagnostic": {
"description": "Show a squiggly line where the error was thrown. This also enables the error count in the File Tab.",
"type": "boolean",
"default": true
"default": true,
"scope": "resource"
},
"vitest.showImportsDuration": {
"description": "Show how long it took to import the module during the last test run. If multiple isolated tests imported the module, the times will be aggregated.",
"type": "boolean",
"default": true
"default": true,
"scope": "resource"
},
"vitest.showInlineConsoleLog": {
"description": "Show inline console.log messages in the editor. When disabled, console logs will still appear in the test output but not inline next to the code.",
"type": "boolean",
"default": true,
"scope": "resource"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/extension/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function getConfig(workspaceFolder?: WorkspaceFolder) {
const debugOutFiles = get<string[]>('debugOutFiles', [])
const applyDiagnostic = get<boolean>('applyDiagnostic', true)
const ignoreWorkspace = get<boolean>('ignoreWorkspace', false) ?? false
const showInlineConsoleLog = get<boolean>('showInlineConsoleLog', true) ?? true

return {
env: get<null | Record<string, string>>('nodeEnv', null),
Expand All @@ -98,6 +99,7 @@ export function getConfig(workspaceFolder?: WorkspaceFolder) {
debuggerAddress: get<string>('debuggerAddress', undefined) || undefined,
logLevel,
showImportsDuration: get<boolean>('showImportsDuration', true) ?? true,
showInlineConsoleLog,
}
}

Expand Down
18 changes: 17 additions & 1 deletion packages/extension/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getTasks } from '@vitest/runner/utils'
import { basename, normalize, relative } from 'pathe'
import { normalizeDriveLetter } from 'vitest-vscode-shared'
import * as vscode from 'vscode'
import { getConfig } from './config'
import { coverageContext, readCoverageReport } from './coverage'
import { log } from './log'
import { getTestData, TestCase, TestFile, TestFolder } from './testTreeData'
Expand All @@ -30,6 +31,8 @@ export class TestRunner extends vscode.Disposable {

private cancelled = false

private showInlineConsoleLog = true

constructor(
private readonly controller: vscode.TestController,
private readonly tree: TestTree,
Expand All @@ -49,6 +52,9 @@ export class TestRunner extends vscode.Disposable {
this.disposables = []
})

// Initialize with workspace-specific config
this.showInlineConsoleLog = getConfig(api.workspaceFolder).showInlineConsoleLog

api.onStdout((content) => {
if (this.testRun) {
this.testRun.appendOutput(formatTestOutput(content))
Expand Down Expand Up @@ -163,8 +169,9 @@ export class TestRunner extends vscode.Disposable {
const testRun = this.testRun
if (testRun) {
// Create location from parsed console log for inline display
// Only set location if inline console logs are enabled
let location: vscode.Location | undefined
if (consoleLog.parsedLocation) {
if (consoleLog.parsedLocation && this.showInlineConsoleLog) {
const uri = vscode.Uri.file(consoleLog.parsedLocation.file)
const position = new vscode.Position(
consoleLog.parsedLocation.line,
Expand All @@ -183,6 +190,15 @@ export class TestRunner extends vscode.Disposable {
log.info('[TEST]', consoleLog.content)
}
})

// Listen to configuration changes
this.disposables.push(
vscode.workspace.onDidChangeConfiguration((event) => {
if (event.affectsConfiguration('vitest.showInlineConsoleLog', api.workspaceFolder.uri)) {
this.showInlineConsoleLog = getConfig(api.workspaceFolder).showInlineConsoleLog
}
}),
)
}

protected endTestRun() {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.tsbuildinfo

This file was deleted.

Loading