Skip to content

Commit

Permalink
fix(reporter): close junit file handle
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 9, 2023
1 parent 07092c4 commit 9263e25
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vitest/src/node/reporters/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class JUnitReporter implements Reporter {
private baseLog!: (text: string) => Promise<void>
private logger!: IndentedLogger<Promise<void>>
private _timeStart = new Date()
private fileFd?: fs.FileHandle

async onInit(ctx: Vitest): Promise<void> {
this.ctx = ctx
Expand All @@ -89,6 +90,7 @@ export class JUnitReporter implements Reporter {
await fs.mkdir(outputDirectory, { recursive: true })

const fileFd = await fs.open(this.reportFile, 'w+')
this.fileFd = fileFd

this.baseLog = async (text: string) => await fs.writeFile(fileFd, `${text}\n`)
}
Expand Down Expand Up @@ -244,5 +246,7 @@ export class JUnitReporter implements Reporter {

if (this.reportFile)
this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`)

await this.fileFd?.close()
}
}

0 comments on commit 9263e25

Please sign in to comment.