MCPcopy
hub / github.com/vitest-dev/vitest / onWatcherStart

Function onWatcherStart

packages/vitest/src/node/reporters/base.ts:382–405  ·  view source on GitHub ↗
(files: File[] = this.ctx.state.getFiles(), errors: unknown[] = this.ctx.state.getUnhandledErrors())

Source from the content-addressed store, hash-verified

380 }
381
382 onWatcherStart(files: File[] = this.ctx.state.getFiles(), errors: unknown[] = this.ctx.state.getUnhandledErrors()): void {
383 const failed = errors.length > 0 || hasFailed(files)
384
385 if (failed) {
386 this.log(withLabel('red', 'FAIL', 'Tests failed. Watching for file changes...'))
387 }
388 else if (this.ctx.isCancelling) {
389 this.log(withLabel('red', 'CANCELLED', 'Test run cancelled. Watching for file changes...'))
390 }
391 else {
392 this.log(withLabel('green', 'PASS', 'Waiting for file changes...'))
393 }
394
395 const hints = [c.dim('press ') + c.bold('h') + c.dim(' to show help')]
396
397 if (hasFailedSnapshot(files)) {
398 hints.unshift(c.dim('press ') + c.bold(c.yellow('u')) + c.dim(' to update snapshot'))
399 }
400 else {
401 hints.push(c.dim('press ') + c.bold('q') + c.dim(' to quit'))
402 }
403
404 this.log(BADGE_PADDING + hints.join(c.dim(', ')))
405 }
406
407 onWatcherRerun(files: string[], trigger?: string): void {
408 this.watchFilters = files

Callers

nothing calls this directly

Calls 6

hasFailedFunction · 0.90
withLabelFunction · 0.90
hasFailedSnapshotFunction · 0.90
getUnhandledErrorsMethod · 0.80
getFilesMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected