Skip to content

Commit

Permalink
feat: remove deprecated options (#5696)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored May 9, 2024
1 parent 1db23d0 commit 5c308ed
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 32 deletions.
5 changes: 1 addition & 4 deletions packages/ui/node/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import c from 'picocolors'
import fg from 'fast-glob'
import { stringify } from 'flatted'
import type { File, ModuleGraphData, Reporter, ResolvedConfig, Vitest } from 'vitest'
import type { HTMLOptions } from 'vitest/node'
import { getModuleGraph } from '../../vitest/src/utils/graph'

export interface HTMLOptions {
outputFile?: string
}

interface PotentialConfig {
outputFile?: string | Partial<Record<string, string>>
}
Expand Down
2 changes: 0 additions & 2 deletions packages/vitest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export * from './integrations/chai'
export * from './integrations/vi'
export * from './integrations/utils'
export { inject } from './integrations/inject'
// TODO: remove in 2.0.0, import from vitest/snapshot directly
export type { SnapshotEnvironment } from '@vitest/snapshot/environment'

export * from './types'
export * from './api/types'
7 changes: 0 additions & 7 deletions packages/vitest/src/node/cli/cac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ export function createCLI(options: CLIOptions = {}) {
benchCliOptionsConfig,
)

// TODO: remove in Vitest 2.0
cli
.command('typecheck [...filters]')
.action(() => {
throw new Error(`Running typecheck via "typecheck" command is removed. Please use "--typecheck" to run your regular tests alongside typechecking, or "--typecheck.only" to run only typecheck tests.`)
})

cli
.command('[...filters]', undefined, options)
.action((filters, options) => start('test', filters, options))
Expand Down
5 changes: 0 additions & 5 deletions packages/vitest/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ export function resolveConfig(
}
}

// TODO: V2.0.0 remove
// @ts-expect-error -- check for removed API option
if (resolved.coverage.provider === 'c8')
throw new Error('"coverage.provider: c8" is not supported anymore. Use "coverage.provider: v8" instead')

if (resolved.coverage.provider === 'v8' && resolved.coverage.enabled && isBrowserEnabled(resolved))
throw new Error('@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead')

Expand Down
10 changes: 9 additions & 1 deletion packages/vitest/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ export { VitestPackageInstaller } from './packageInstaller'
export type { TestSequencer, TestSequencerConstructor } from './sequencers/types'
export { BaseSequencer } from './sequencers/BaseSequencer'

export type { BrowserProviderInitializationOptions, BrowserProvider, BrowserProviderOptions, BrowserScript } from '../types/browser'
export type {
BrowserProviderInitializationOptions,
BrowserProvider,
BrowserProviderOptions,
BrowserScript,
} from '../types/browser'
export type { JsonOptions } from './reporters/json'
export type { JUnitOptions } from './reporters/junit'
export type { HTMLOptions } from './reporters/html'
3 changes: 3 additions & 0 deletions packages/vitest/src/node/reporters/html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface HTMLOptions {
outputFile?: string
}
3 changes: 2 additions & 1 deletion packages/vitest/src/node/reporters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TapFlatReporter } from './tap-flat'
import { HangingProcessReporter } from './hanging-process'
import { GithubActionsReporter } from './github-actions'
import type { BaseReporter } from './base'
import type { HTMLOptions } from './html'

export {
DefaultReporter,
Expand Down Expand Up @@ -52,7 +53,7 @@ export interface BuiltinReporterOptions {
'tap-flat': never
'junit': JUnitOptions
'hanging-process': never
'html': { outputFile?: string } // TODO: Any better place for defining this UI package's reporter options?
'html': HTMLOptions
}

export * from './benchmark'
6 changes: 2 additions & 4 deletions packages/vitest/src/node/reporters/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ export class JUnitReporter implements Reporter {
async writeTasks(tasks: Task[], filename: string): Promise<void> {
for (const task of tasks) {
await this.writeElement('testcase', {
// TODO: v2.0.0 Remove env variable in favor of custom reporter options, e.g. "reporters: [['json', { classname: 'something' }]]"
classname: this.options.classname ?? process.env.VITEST_JUNIT_CLASSNAME ?? filename,
classname: this.options.classname ?? filename,
file: this.options.addFileAttribute ? filename : undefined,
name: task.name,
time: getDuration(task),
Expand Down Expand Up @@ -264,8 +263,7 @@ export class JUnitReporter implements Reporter {
stats.failures += file.stats.failures
return stats
}, {
// TODO: v2.0.0 Remove env variable in favor of custom reporter options, e.g. "reporters: [['json', { suiteName: 'something' }]]"
name: this.options.suiteName || process.env.VITEST_JUNIT_SUITE_NAME || 'vitest tests',
name: this.options.suiteName || 'vitest tests',
tests: 0,
failures: 0,
errors: 0, // we cannot detect those
Expand Down
1 change: 0 additions & 1 deletion packages/vitest/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ export interface InlineConfig {
*/
reporters?: Arrayable<ReporterName | InlineReporter> | ((ReporterName | InlineReporter) | [ReporterName] | ReporterWithOptions)[]

// TODO: v2.0.0 Remove in favor of custom reporter options, e.g. "reporters: [['json', { outputFile: 'some-dir/file.html' }]]"
/**
* Write test results to a file when the --reporter=json` or `--reporter=junit` option is also specified.
* Also definable individually per reporter by using an object instead.
Expand Down
7 changes: 0 additions & 7 deletions test/config/test/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ test('inspect-brk cannot be used with multi processing', async () => {
expect(stderr).toMatch('Error: You cannot use --inspect without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"')
})

test('c8 coverage provider is not supported', async () => {
// @ts-expect-error -- check for removed API option
const { stderr } = await runVitest({ coverage: { enabled: true, provider: 'c8' } })

expect(stderr).toMatch('Error: "coverage.provider: c8" is not supported anymore. Use "coverage.provider: v8" instead')
})

test('v8 coverage provider cannot be used with browser', async () => {
const { stderr } = await runVitest({ coverage: { enabled: true }, browser: { enabled: true, name: 'chrome' } })

Expand Down

0 comments on commit 5c308ed

Please sign in to comment.