Skip to content

Commit

Permalink
fix: report untested files when running the whole suite
Browse files Browse the repository at this point in the history
Fixes #361
  • Loading branch information
sheremet-va committed Apr 23, 2024
1 parent 026f945 commit ccab32a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/worker/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class VitestCoverage {
this._config.reportOnFailure = true
this._config.reportsDirectory = join(tmpdir(), `vitest-coverage-${randomUUID()}`)

this.ctx.logger.log('Coverage reports directory is generated:', this._config.reportsDirectory)
this.ctx.logger.log('Running coverage with configuration:', this._config)

if (!this._provider) {
// @ts-expect-error private method
Expand Down
10 changes: 5 additions & 5 deletions src/worker/vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Vitest implements VitestMethods {
}
else {
const specs = await this.globTestFiles(files)
await this.runTestFiles(specs.map(([_, spec]) => spec))
await this.runTestFiles(specs.map(([_, spec]) => spec), undefined, !files)
}
}

Expand All @@ -82,15 +82,15 @@ export class Vitest implements VitestMethods {
return files
}

private async runTestFiles(files: string[], testNamePattern?: string | undefined) {
private async runTestFiles(files: string[], testNamePattern?: string | undefined, runAllFiles = false) {
await this.ctx.runningPromise
this.watcher.markRerun(false)
process.chdir(this.cwd)

try {
this.setTestNamePattern(testNamePattern)

await this.rerunTests(files)
await this.rerunTests(files, runAllFiles)
}
finally {
process.chdir(cwd)
Expand All @@ -101,9 +101,9 @@ export class Vitest implements VitestMethods {
this.ctx.configOverride.testNamePattern = pattern ? new RegExp(pattern) : undefined
}

private async rerunTests(files: string[]) {
private async rerunTests(files: string[], runAllFiles = false) {
await this.ctx.report('onWatcherRerun', files)
await this.ctx.runFiles(files.flatMap(file => this.ctx.getProjectsByTestFile(file)), false)
await this.ctx.runFiles(files.flatMap(file => this.ctx.getProjectsByTestFile(file)), runAllFiles)

await this.ctx.report('onWatcherStart', this.ctx.state.getFiles(files))
}
Expand Down

0 comments on commit ccab32a

Please sign in to comment.