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
6 changes: 2 additions & 4 deletions docs/advanced/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class CustomReporter extends BaseReporter {
Or implement the `Reporter` interface:

```ts [custom-reporter.js]
import { Reporter } from 'vitest/reporters'
import type { Reporter } from 'vitest/node'

export default class CustomReporter implements Reporter {
onCollected() {
Expand Down Expand Up @@ -65,9 +65,7 @@ Instead of using the tasks that reporters receive, it is recommended to use the
You can get access to this API by calling `vitest.state.getReportedEntity(runnerTask)`:

```ts twoslash
import type { Vitest } from 'vitest/node'
import type { RunnerTestFile } from 'vitest'
import type { Reporter, TestModule } from 'vitest/reporters'
import type { Reporter, RunnerTestFile, TestModule, Vitest } from 'vitest/node'

class MyReporter implements Reporter {
private vitest!: Vitest
Expand Down
4 changes: 4 additions & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ The [`resolveConfig`](/advanced/api/#resolveconfig) is now more useful. Instead

This function is not used internally and exposed exclusively as a public API.

### Cleaned up `vitest/reporters` types <Badge type="danger">API</Badge> {#cleaned-up-vitest-reporters-types}

The `vitest/reporters` entrypoint now only exports reporters implementations and options types. If you need access to `TestCase`/`TestSuite` and other task related types, import them additionally from `vitest/node`.

## Migrating to Vitest 2.0 {#vitest-2}

### Default Pool is `forks`
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli/cli-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { UserConfig as ViteUserConfig } from 'vite'
import type { environments } from '../../integrations/env'
import type { Vitest, VitestOptions } from '../core'
import type { TestModule, TestSuite } from '../reporters'
import type { TestModule, TestSuite } from '../reporters/reported-tasks'
import type { TestSpecification } from '../spec'
import type { UserConfig, VitestEnvironment, VitestRunMode } from '../types/config'
import { mkdirSync, writeFileSync } from 'node:fs'
Expand Down
5 changes: 5 additions & 0 deletions packages/vitest/src/node/reporters/benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { BenchmarkReporter } from './reporter'
import { VerboseBenchmarkReporter } from './verbose'

export {
BenchmarkReporter,
VerboseBenchmarkReporter,
}

export const BenchmarkReportsMap = {
default: BenchmarkReporter,
verbose: VerboseBenchmarkReporter,
Expand Down
32 changes: 6 additions & 26 deletions packages/vitest/src/node/reporters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { BaseOptions, BaseReporter } from './base'
import type { BlobOptions } from './blob'
import type { DefaultReporterOptions } from './default'
import type { HTMLOptions } from './html'
import type { ModuleDiagnostic as _FileDiagnostic } from './reported-tasks'
import { BasicReporter } from './basic'
import { BlobReporter } from './blob'
import { DefaultReporter } from './default'
Expand All @@ -12,7 +11,6 @@ import { GithubActionsReporter } from './github-actions'
import { HangingProcessReporter } from './hanging-process'
import { type JsonOptions, JsonReporter } from './json'
import { type JUnitOptions, JUnitReporter } from './junit'
import { TestModule as _TestFile } from './reported-tasks'
import { TapReporter } from './tap'
import { TapFlatReporter } from './tap-flat'
import { VerboseReporter } from './verbose'
Expand All @@ -31,23 +29,17 @@ export {
}
export type { BaseReporter, Reporter }

export type { TestProject } from '../project'
/**
* @deprecated Use `TestModule` instead
*/
export const TestFile = _TestFile
export * from './benchmark'
export {
BenchmarkBuiltinReporters,
BenchmarkReporter,
BenchmarkReportsMap,
VerboseBenchmarkReporter,
} from './benchmark'
export type {
JsonAssertionResult,
JsonTestResult,
JsonTestResults,
} from './json'
/**
* @deprecated Use `ModuleDiagnostic` instead
*/
export type FileDiagnostic = _FileDiagnostic

export { TestCase, TestModule, TestSuite } from './reported-tasks'

export const ReportersMap = {
'default': DefaultReporter,
Expand Down Expand Up @@ -78,15 +70,3 @@ export interface BuiltinReporterOptions {
'hanging-process': never
'html': HTMLOptions
}

export type {
TaskOptions,

TestCollection,
TestDiagnostic,

TestResult,
TestResultFailed,
TestResultPassed,
TestResultSkipped,
} from './reported-tasks'
2 changes: 1 addition & 1 deletion packages/vitest/src/node/specifications.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Vitest } from './core'
import type { TestProject } from './reporters'
import type { TestProject } from './project'
import type { TestSpecification } from './spec'
import { existsSync } from 'node:fs'
import mm from 'micromatch'
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/types/tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TestModule } from '../reporters'
import type { TestModule } from '../reporters/reported-tasks'

export interface TestRunResult {
testModules: TestModule[]
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Vitest } from './core'
import type { TestProject } from './reporters'
import type { TestProject } from './project'
import { readFileSync } from 'node:fs'
import { noop, slash } from '@vitest/utils'
import mm from 'micromatch'
Expand Down
11 changes: 11 additions & 0 deletions packages/vitest/src/public/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ export type {

export { createDebugger } from '../utils/debugger'

export type {
RunnerTask,
RunnerTaskResult,
RunnerTaskResultPack,
RunnerTestCase,
RunnerTestFile,
RunnerTestSuite,
} from './index'
export type {
Reporter,
} from './reporters'
export { generateFileHash } from '@vitest/runner/utils'

export {
Expand Down
27 changes: 26 additions & 1 deletion packages/vitest/src/public/reporters.ts
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
export * from '../node/reporters'
export {
BasicReporter,
BenchmarkReporter,
BenchmarkReportsMap,
DefaultReporter,
DotReporter,
GithubActionsReporter,
HangingProcessReporter,
JsonReporter,
JUnitReporter,
ReportersMap,
TapFlatReporter,
TapReporter,
VerboseBenchmarkReporter,
VerboseReporter,
} from '../node/reporters'
export type {
BaseReporter,
BenchmarkBuiltinReporters,
BuiltinReporterOptions,
BuiltinReporters,
JsonAssertionResult,
JsonTestResult,
JsonTestResults,
Reporter,
} from '../node/reporters'
3 changes: 1 addition & 2 deletions test/reporters/tests/task-parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { File, Test } from '@vitest/runner'
import type { TestSpecification } from 'vitest/node'
import type { Reporter } from 'vitest/reporters'
import type { Reporter, TestSpecification } from 'vitest/node'
import type { HookOptions } from '../../../packages/vitest/src/node/reporters/task-parser'
import { expect, test } from 'vitest'
import { TaskParser } from '../../../packages/vitest/src/node/reporters/task-parser'
Expand Down
Loading