From c65214822a06639e915128496e0534184f219d2f Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Fri, 15 Mar 2024 10:35:00 +0100 Subject: [PATCH] chore: remove unused property --- packages/vitest/src/node/core.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/vitest/src/node/core.ts b/packages/vitest/src/node/core.ts index a2d3d3154a2a..18146a0c1e4f 100644 --- a/packages/vitest/src/node/core.ts +++ b/packages/vitest/src/node/core.ts @@ -13,7 +13,6 @@ import type { defineWorkspace } from 'vitest/config' import type { ArgumentsType, CoverageProvider, OnServerRestartHandler, Reporter, ResolvedConfig, UserConfig, UserWorkspaceConfig, VitestRunMode } from '../types' import { hasFailed, noop, slash, toArray, wildcardPatternToRegExp } from '../utils' import { getCoverageProvider } from '../integrations/coverage' -import type { BrowserProvider } from '../types/browser' import { CONFIG_NAMES, configFiles, workspacesFiles as workspaceFiles } from '../constants' import { rootDir } from '../paths' import { WebSocketReporter } from '../api/setup' @@ -43,7 +42,6 @@ export class Vitest { cache: VitestCache = undefined! reporters: Reporter[] = undefined! coverageProvider: CoverageProvider | null | undefined - browserProvider: BrowserProvider | undefined logger: Logger pool: ProcessPool | undefined @@ -51,6 +49,7 @@ export class Vitest { invalidates: Set = new Set() changedTests: Set = new Set() + watchedTests: Set = new Set() filenamePattern?: string runningPromise?: Promise closingPromise?: Promise @@ -623,6 +622,14 @@ export class Vitest { return this._rerunTimer = setTimeout(async () => { + // run only watched tests + if (this.watchedTests.size) { + this.changedTests.forEach((test) => { + if (!this.watchedTests.has(test)) + this.changedTests.delete(test) + }) + } + if (this.changedTests.size === 0) { this.invalidates.clear() return @@ -665,6 +672,15 @@ export class Vitest { }) } + /** + * Watch only the specified tests. If no tests are provided, all tests will be watched. + */ + public watchTests(tests: string[]) { + this.watchedTests = new Set( + tests.map(test => slash(test)), + ) + } + private unregisterWatcher = noop private registerWatcher() { const updateLastChanged = (filepath: string) => {