Skip to content

Commit

Permalink
chore: remove unused property
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Mar 15, 2024
1 parent ce5ca6b commit c652148
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -43,14 +42,14 @@ export class Vitest {
cache: VitestCache = undefined!
reporters: Reporter[] = undefined!
coverageProvider: CoverageProvider | null | undefined
browserProvider: BrowserProvider | undefined
logger: Logger
pool: ProcessPool | undefined

vitenode: ViteNodeServer = undefined!

invalidates: Set<string> = new Set()
changedTests: Set<string> = new Set()
watchedTests: Set<string> = new Set()
filenamePattern?: string
runningPromise?: Promise<void>
closingPromise?: Promise<void>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit c652148

Please sign in to comment.