/
data-for-junit.ts
59 lines (51 loc) · 1.36 KB
/
data-for-junit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { AssertionError } from 'assert'
import type { File, Suite, Task } from 'vitest'
function createSuiteHavingFailedTestWithXmlInError(): File[] {
const file: File = {
id: '1223128da3',
name: 'test/core/test/basic.test.ts',
type: 'suite',
mode: 'run',
filepath: '/vitest/test/core/test/basic.test.ts',
result: { state: 'fail', duration: 145.99284195899963 },
tasks: [],
}
const suite: Suite = {
id: '',
type: 'suite',
name: 'suite',
mode: 'run',
file,
result: { state: 'pass', duration: 1.90183687210083 },
tasks: [],
}
const errorWithXml = new AssertionError({
message: 'error message that has XML in it <tag>',
})
errorWithXml.stack = 'Error: error message that has XML in it <tag>\n'
+ ' at /vitest/test/core/test/basic.test.ts:8:32\n'
+ ' at /vitest/test/core/test/<bracket-name>.ts:3:11\n'
+ ' at etc....'
const tasks: Task[] = [
{
id: '123_0',
type: 'test',
name: 'test with xml in error',
mode: 'run',
suite,
fails: undefined,
file,
result: {
state: 'fail',
error: errorWithXml,
errors: [errorWithXml],
duration: 2.123123123,
},
context: null as any,
},
]
file.tasks = [suite]
suite.tasks = tasks
return [file]
}
export { createSuiteHavingFailedTestWithXmlInError }