Skip to content

Commit

Permalink
fix: watch mode's filename pattern to persist re-run of failed tests,…
Browse files Browse the repository at this point in the history
… snapshot updates and testname filter changes
  • Loading branch information
AriPerkkio authored and sheremet-va committed Jan 27, 2023
1 parent 712ac15 commit 1c65ac4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/vitest/src/node/core.ts
Expand Up @@ -360,6 +360,11 @@ export class Vitest {
}

async rerunFiles(files: string[] = this.state.getFilepaths(), trigger?: string) {
if (this.filenamePattern) {
const filteredFiles = await this.globTestFiles([this.filenamePattern])
files = files.filter(file => filteredFiles.includes(file))
}

if (this.coverageProvider && this.config.coverage.cleanOnRerun)
await this.coverageProvider.clean()

Expand All @@ -385,10 +390,9 @@ export class Vitest {
this.filenamePattern = pattern

const files = this.state.getFilepaths()
if (!this.filenamePattern)
return await this.rerunFiles(files, 'reset filename pattern')
const filteredFiles = await this.globTestFiles([this.filenamePattern])
await this.rerunFiles(filteredFiles, 'change filename pattern')
const trigger = this.filenamePattern ? 'change filename pattern' : 'reset filename pattern'

await this.rerunFiles(files, trigger)
}

async rerunFailed() {
Expand Down

0 comments on commit 1c65ac4

Please sign in to comment.