Skip to content

Commit 900b517

Browse files
committed
fix(reporter)!: mark onTaskUpdate as @internal
1 parent d253085 commit 900b517

File tree

5 files changed

+14
-25
lines changed

5 files changed

+14
-25
lines changed

packages/vitest/src/node/types/reporter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ export interface Reporter {
1616
* @experimental
1717
*/
1818
onBrowserInit?: (project: TestProject) => Awaitable<void>
19-
/**
20-
* @deprecated use `onTestModuleQueued`, `onTestModuleStart`, `onTestModuleEnd`, `onTestCaseReady`, `onTestCaseResult` instead
21-
*/
19+
/** @internal */
2220
onTaskUpdate?: (packs: TaskResultPack[], events: TaskEventPack[]) => Awaitable<void>
2321
onTestRemoved?: (trigger?: string) => Awaitable<void>
2422
onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>

test/browser/specs/runner.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ describe('running browser tests', async () => {
3636
onTestRunStart: noop,
3737
onTestModuleCollected: noop,
3838
onTestRunEnd: noop,
39-
onTaskUpdate: noop,
4039
onTestRemoved: noop,
4140
onWatcherStart: noop,
4241
onWatcherRerun: noop,

test/cli/test/public-api.test.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { RunnerTaskResultPack } from 'vitest'
1+
import type { TaskMeta } from '@vitest/runner'
22
import type { TestModule, TestUserConfig } from 'vitest/node'
33
import { resolve } from 'pathe'
44
import { expect, it } from 'vitest'
@@ -15,7 +15,9 @@ it.each([
1515
},
1616
},
1717
] as TestUserConfig[])('passes down metadata when $name', { timeout: 60_000, retry: 1 }, async (config) => {
18-
const taskUpdate: RunnerTaskResultPack[] = []
18+
const finishedTestCaseMetas: TaskMeta[] = []
19+
const finishedTestModuleMetas: TaskMeta[] = []
20+
1921
const finishedTestModules: TestModule[] = []
2022
const collectedTestModules: TestModule[] = []
2123
const { ctx, stdout, stderr } = await runVitest({
@@ -24,8 +26,11 @@ it.each([
2426
reporters: [
2527
['verbose', { isTTY: false }],
2628
{
27-
onTaskUpdate(packs) {
28-
taskUpdate.push(...packs.filter(i => i[1]?.state === 'pass'))
29+
onTestCaseResult(testCase) {
30+
finishedTestCaseMetas.push(testCase.meta())
31+
},
32+
onTestModuleEnd(testModule) {
33+
finishedTestModuleMetas.push(testModule.meta())
2934
},
3035
onTestRunEnd(testModules) {
3136
finishedTestModules.push(...testModules)
@@ -46,27 +51,16 @@ it.each([
4651
const suiteMeta = { done: true }
4752
const testMeta = { custom: 'some-custom-hanlder' }
4853

49-
expect(taskUpdate).toHaveLength(4)
54+
expect(finishedTestCaseMetas).toHaveLength(3)
55+
expect(finishedTestModuleMetas).toHaveLength(1)
5056
expect(finishedTestModules).toHaveLength(1)
5157

5258
const files = ctx?.state.getFiles() || []
5359
expect(files).toHaveLength(1)
5460

55-
expect(taskUpdate).toContainEqual(
56-
[
57-
expect.any(String),
58-
expect.anything(),
59-
suiteMeta,
60-
],
61-
)
61+
expect(finishedTestModuleMetas).toContainEqual(suiteMeta)
6262

63-
expect(taskUpdate).toContainEqual(
64-
[
65-
expect.any(String),
66-
expect.anything(),
67-
testMeta,
68-
],
69-
)
63+
expect(finishedTestCaseMetas).toContainEqual(testMeta)
7064

7165
const test = finishedTestModules[0].children.tests().next().value!
7266

test/reporters/tests/console.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { runVitest } from '../../test-utils'
77

88
class LogReporter extends DefaultReporter {
99
isTTY = true
10-
onTaskUpdate() {}
1110
}
1211

1312
test('should print logs correctly', async () => {

test/reporters/tests/silent.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,4 @@ Log from failed suite`,
101101

102102
class LogReporter extends DefaultReporter {
103103
isTTY = true
104-
onTaskUpdate() {}
105104
}

0 commit comments

Comments
 (0)