(ctx: Vitest)
| 131 | } |
| 132 | |
| 133 | async onInit(ctx: Vitest): Promise<void> { |
| 134 | this.ctx = ctx |
| 135 | |
| 136 | const outputFile |
| 137 | = this.options.outputFile ?? getOutputFile(this.ctx.config, 'junit') |
| 138 | |
| 139 | if (outputFile) { |
| 140 | this.reportFile = resolve(this.ctx.config.root, outputFile) |
| 141 | |
| 142 | const outputDirectory = dirname(this.reportFile) |
| 143 | if (!existsSync(outputDirectory)) { |
| 144 | await fs.mkdir(outputDirectory, { recursive: true }) |
| 145 | } |
| 146 | |
| 147 | const fileFd = await fs.open(this.reportFile, 'w+') |
| 148 | this.fileFd = fileFd |
| 149 | |
| 150 | this.baseLog = async (text: string) => { |
| 151 | if (!this.fileFd) { |
| 152 | this.fileFd = await fs.open(this.reportFile!, 'w+') |
| 153 | } |
| 154 | |
| 155 | await fs.writeFile(this.fileFd, `${text}\n`) |
| 156 | } |
| 157 | } |
| 158 | else { |
| 159 | this.baseLog = async (text: string) => this.ctx.logger.log(text) |
| 160 | } |
| 161 | |
| 162 | this._timeStart = new Date() |
| 163 | this.logger = new IndentedLogger(this.baseLog) |
| 164 | } |
| 165 | |
| 166 | async writeElement( |
| 167 | name: string, |
nothing calls this directly
no test coverage detected