Skip to content

Commit

Permalink
fix: rerun _all_ tests when pressing "a" or "return"
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Apr 23, 2024
1 parent 957706f commit 4908339
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,10 @@ export class Vitest {
)))
}

public async getTestFilepaths() {
return this.globTestFiles().then(files => files.map(([, file]) => file))
}

public async globTestFiles(filters: string[] = []) {
const files: WorkspaceSpec[] = []
await Promise.all(this.projects.map(async (project) => {
Expand Down
8 changes: 5 additions & 3 deletions packages/vitest/src/node/stdin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export function registerConsoleShortcuts(ctx: Vitest) {
if (name === 'u')
return ctx.updateSnapshot()
// rerun all tests
if (name === 'a' || name === 'return')
return ctx.changeNamePattern('')
if (name === 'a' || name === 'return') {
const files = await ctx.getTestFilepaths()
return ctx.changeNamePattern('', files, 'rerun all tests')
}
// rerun current pattern tests
if (name === 'r')
return ctx.rerunFiles()
Expand Down Expand Up @@ -115,7 +117,7 @@ export function registerConsoleShortcuts(ctx: Vitest) {
const files = ctx.state.getFilepaths()
// if running in standalone mode, Vitest instance doesn't know about any test file
const cliFiles = ctx.config.standalone && !files.length
? (await ctx.globTestFiles()).map(([_, file]) => file)
? await ctx.getTestFilepaths()
: undefined

await ctx.changeNamePattern(filter?.trim() || '', cliFiles, 'change pattern')
Expand Down

0 comments on commit 4908339

Please sign in to comment.