Skip to content

Commit

Permalink
fix(reporter): clear previous state on rerun
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 8, 2022
1 parent c5d07b8 commit f714833
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/vitest/src/node/core.ts
Expand Up @@ -227,8 +227,10 @@ export class Vitest {
}

async runFiles(paths: string[]) {
// previous run
await this.runningPromise

// schedule the new run
this.runningPromise = (async () => {
if (!this.pool)
this.pool = createPool(this)
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/node/pool.ts
Expand Up @@ -67,6 +67,7 @@ export function createPool(ctx: Vitest): WorkerPool {
let id = 0

async function runFiles(config: ResolvedConfig, files: string[], invalidates: string[] = []) {
ctx.state.clearFiles(files)
const { workerPort, port } = createChannel(ctx)
const workerId = ++id
const data: WorkerContext = {
Expand Down
6 changes: 6 additions & 0 deletions packages/vitest/src/node/state.ts
Expand Up @@ -54,6 +54,12 @@ export class StateManager {
})
}

clearFiles(paths: string[] = []) {
paths.forEach((path) => {
this.filesMap.delete(path)
})
}

updateId(task: Task) {
if (this.idMap.get(task.id) === task)
return
Expand Down

0 comments on commit f714833

Please sign in to comment.