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

Method writeElement

packages/vitest/src/node/reporters/junit.ts:166–189  ·  view source on GitHub ↗
(
    name: string,
    attrs: Record<string, any>,
    children: () => Promise<void>,
  )

Source from the content-addressed store, hash-verified

164 }
165
166 async writeElement(
167 name: string,
168 attrs: Record<string, any>,
169 children: () => Promise<void>,
170 ): Promise<void> {
171 const pairs: string[] = []
172 for (const key in attrs) {
173 const attr = attrs[key]
174 if (attr === undefined) {
175 continue
176 }
177
178 pairs.push(`${key}="${escapeXML(attr)}"`)
179 }
180
181 await this.logger.log(
182 `<${name}${pairs.length ? ` ${pairs.join(' ')}` : ''}>`,
183 )
184 this.logger.indent()
185 await children.call(this)
186 this.logger.unindent()
187
188 await this.logger.log(`</${name}>`)
189 }
190
191 async writeLogs(task: Task, type: 'err' | 'out'): Promise<void> {
192 if (task.logs == null || task.logs.length === 0) {

Callers 3

writeLogsMethod · 0.95
writeTasksMethod · 0.95
onTestRunEndMethod · 0.95

Calls 4

escapeXMLFunction · 0.85
indentMethod · 0.80
unindentMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected