MCPcopy
hub / github.com/vitest-dev/vitest / onInit

Method onInit

packages/vitest/src/node/reporters/junit.ts:133–164  ·  view source on GitHub ↗
(ctx: Vitest)

Source from the content-addressed store, hash-verified

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,

Callers

nothing calls this directly

Calls 4

getOutputFileFunction · 0.90
openMethod · 0.80
resolveFunction · 0.50
logMethod · 0.45

Tested by

no test coverage detected