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
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ jobs:

- name: Link CI reports
run: |
echo "::notice title=CI reports::test/unit: ${{ steps.upload-unit-report.outputs.artifact-url }}"
echo "::notice title=CI reports::test/e2e: ${{ steps.upload-e2e-report.outputs.artifact-url }}"
echo "::notice title=CI reports::packages/ui: ${{ steps.upload-ui-report.outputs.artifact-url }}"
echo "::notice title=CI reports::test/unit: ${STEPS_UPLOAD_UNIT_REPORT_OUTPUTS_ARTIFACT_URL}"
echo "::notice title=CI reports::test/e2e: ${STEPS_UPLOAD_E2E_REPORT_OUTPUTS_ARTIFACT_URL}"
echo "::notice title=CI reports::packages/ui: ${STEPS_UPLOAD_UI_REPORT_OUTPUTS_ARTIFACT_URL}"
env:
STEPS_UPLOAD_UNIT_REPORT_OUTPUTS_ARTIFACT_URL: ${{ steps.upload-unit-report.outputs.artifact-url }}
STEPS_UPLOAD_E2E_REPORT_OUTPUTS_ARTIFACT_URL: ${{ steps.upload-e2e-report.outputs.artifact-url }}
STEPS_UPLOAD_UI_REPORT_OUTPUTS_ARTIFACT_URL: ${{ steps.upload-ui-report.outputs.artifact-url }}
1 change: 1 addition & 0 deletions .github/workflows/pr-labeled-automated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
agent-scan-comment: false
skip-comment-on-organic: true

# just put a label and send a comment if the account looks suspicious
- name: Label flagged PR
Expand Down
10 changes: 3 additions & 7 deletions docs/config/disableconsoleintercept.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ outline: deep
- **CLI:** `--disableConsoleIntercept`
- **Default:** `false`

By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc.
By default, Vitest intercepts console output during tests to add context such as the test file and test title.

This is also required for console log preview on Vitest UI.
In [browser mode](/guide/browser/), this interception is required to forward logs from the browser DevTools to the terminal. It is also required for console log previews in the Vitest UI.

However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.

::: warning
This option has no effect on [browser tests](/guide/browser/) since Vitest preserves original logging in browser devtools.
:::
Disabling console interception can be useful when you want to debug code with normal synchronous terminal logging.
4 changes: 3 additions & 1 deletion packages/browser/src/client/tester/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ async function prepareTestEnvironment(options: PrepareOptions) {
// @ts-expect-error mocking vitest apis
globalThis.__vitest_mocker__ = mocker

setupConsoleLogSpy()
if (!config.disableConsoleIntercept) {
setupConsoleLogSpy()
}
setupDialogsSpy()

const runner = await initiateRunner(state, mocker, config)
Expand Down
10 changes: 6 additions & 4 deletions packages/ui/client/components/views/ViewEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { getAttachmentUrl, sanitizeFilePath } from '~/composables/attachments'
import { client, config, isReport } from '~/composables/client'
import { finished } from '~/composables/client/state'
import { codemirrorRef } from '~/composables/codemirror'
import { openInEditor } from '~/composables/error'
import { isDark } from '~/composables/dark'
import { createAnsiToHtmlFilter, openInEditor } from '~/composables/error'
import { columnNumber, lineNumber } from '~/composables/params'
import {
activeTraceView,
Expand All @@ -18,6 +19,7 @@ import {
isTraceViewEnabled,
selectActiveTraceStep,
} from '~/composables/trace-view'
import { escapeHtml } from '~/utils/escape'
import CodeMirrorContainer from '../CodeMirrorContainer.vue'

const props = defineProps<{
Expand Down Expand Up @@ -225,12 +227,12 @@ function createErrorElement(e: TestError) {
return
}
const div = document.createElement('div')
div.dataset.testid = 'error-line-gadget'
div.className = 'op80 flex gap-x-2 items-center'
const pre = document.createElement('pre')
pre.className = 'c-red-700 dark:c-red-400'
pre.textContent = `${' '.repeat(stack.column)}^ ${e.name}: ${
e?.message || ''
}`
const filter = createAnsiToHtmlFilter(isDark.value)
pre.innerHTML = `${' '.repeat(stack.column)}^ ${filter.toHtml(escapeHtml(`${e.name}: ${e.message}`))}`
div.appendChild(pre)
const span = document.createElement('span')
span.className
Expand Down
18 changes: 17 additions & 1 deletion packages/vitest/src/integrations/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,17 @@ function createVitest(): VitestUtils {
return function __VITEST_HELPER__(this: any, ...args: any[]): any {
const result = fn.apply(this, args)
if (result && typeof result === 'object' && typeof result.then === 'function') {
const stackTraceError = new Error('STACK_TRACE_ERROR')
return (async function __VITEST_HELPER__() {
return await result
try {
return await result
}
catch (error) {
if (error instanceof Error && !error.stack?.includes('__VITEST_HELPER__')) {
copyStackTrace(error, stackTraceError)
}
throw error
}
})()
}
return result
Expand Down Expand Up @@ -859,3 +868,10 @@ function getImporter(name: string) {
const stack = parseSingleStack(stackArray[importerStackIndex + 1])
return stack?.file || ''
}

function copyStackTrace(target: Error, source: Error) {
if (source.stack !== undefined) {
target.stack = source.stack.replace(source.message, target.message)
}
return target
}
9 changes: 4 additions & 5 deletions packages/vitest/src/node/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,10 @@ export interface InlineConfig {
expandSnapshotDiff?: boolean

/**
* By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc...
* This is also required for console log preview on Vitest UI.
* However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.
*
* This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
* By default, Vitest intercepts console output during tests to add context such as the test file and test title.
* In browser mode, this interception is required to forward logs from the browser DevTools to the terminal.
* It is also required for console log previews in the Vitest UI.
* Disabling console interception can be useful when you want to debug code with normal synchronous terminal logging.
*
* @default false
*/
Expand Down
Loading
Loading