MCPcopy
hub / github.com/vitest-dev/vitest / result

Method result

packages/vitest/src/node/reporters/reported-tasks.ts:150–190  ·  view source on GitHub ↗

* Test results. * - **pending**: Test was collected, but didn't finish running yet. * - **passed**: Test passed successfully * - **failed**: Test failed to execute * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.

()

Source from the content-addressed store, hash-verified

148 * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
149 */
150 public result(): TestResult {
151 const result = this.task.result
152 const mode = result?.state || this.task.mode
153
154 if (!result && (mode === 'skip' || mode === 'todo')) {
155 return {
156 state: 'skipped',
157 note: undefined,
158 errors: undefined,
159 }
160 }
161
162 if (!result || result.state === 'run' || result.state === 'queued') {
163 return {
164 state: 'pending',
165 errors: undefined,
166 }
167 }
168 const state = result.state === 'fail'
169 ? 'failed' as const
170 : result.state === 'pass'
171 ? 'passed' as const
172 : 'skipped' as const
173 if (state === 'skipped') {
174 return {
175 state,
176 note: result.note,
177 errors: undefined,
178 } satisfies TestResultSkipped
179 }
180 if (state === 'passed') {
181 return {
182 state,
183 errors: result.errors as TestError[] | undefined,
184 } satisfies TestResultPassed
185 }
186 return {
187 state,
188 errors: (result.errors || []) as TestError[],
189 } satisfies TestResultFailed
190 }
191
192 /**
193 * Test annotations added via the `task.annotate` API during the test execution.

Callers 15

formatCollectedAsJSONFunction · 0.80
formatCollectedAsStringFunction · 0.80
onTestCaseResultFunction · 0.80
visitFunction · 0.80
printTestCaseFunction · 0.80
getTestCaseSuffixFunction · 0.80
onTestCaseReadyMethod · 0.80
onTestCaseResultMethod · 0.80
onTestCaseResultMethod · 0.80
allTestsMethod · 0.80
testsMethod · 0.80
onTestCaseResultMethod · 0.80

Calls

no outgoing calls

Tested by 2

onTestCaseReadyFunction · 0.64
testItemFunction · 0.64