forked from mainmatter/testem-gitlab-reporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
89 lines (83 loc) · 2.23 KB
/
test.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const GitLabReporter = require('./index');
describe('testem-gitlab-reporter', () => {
test('generates JUnit test results file', () => {
let stream = new MockStream();
let reporter = new GitLabReporter(false, stream);
reporter.report('Chrome 57', {
name: 'Test 1',
passed: true,
failed: 0,
skipped: false,
runDuration: 15,
logs: [],
error: undefined,
});
reporter.report('Chrome 57', {
name: 'Test 2',
passed: true,
failed: 0,
skipped: false,
runDuration: 13,
logs: [],
error: undefined,
});
reporter.report('Chrome 57', {
name: 'Test 3',
passed: false,
failed: 0,
skipped: true,
runDuration: undefined,
logs: [],
error: undefined,
});
reporter.report('Chrome 57', {
name: 'Test 4',
passed: true,
failed: 0,
skipped: false,
runDuration: 123,
logs: [],
error: undefined,
});
reporter.report('Chrome 57', {
name: 'Test 5',
passed: false,
failed: 1,
skipped: false,
runDuration: 42,
logs: [{ type: 'log', text: "'this is a test'\n" }],
error: {
passed: false,
actual: 'My Big Fat Greek Wedding',
expected: 'My Big Fat Greek Funeral',
stack: '[stack hidden - error is assertion error]',
negative: false,
message:
'Assertion failure without message - Actual: My Big Fat Greek Wedding Expected: My Big Fat Greek Funeral',
},
});
reporter.finish();
expect(stream.output).toMatchInlineSnapshot(`
"<?xml version=\\"1.0\\"?>
<testsuite tests=\\"4\\" failures=\\"1\\">
<testcase name=\\"Test 1\\" time=\\"0.015\\"/>
<testcase name=\\"Test 2\\" time=\\"0.013\\"/>
<testcase name=\\"Test 4\\" time=\\"0.123\\"/>
<testcase name=\\"Test 5\\" time=\\"0.042\\">
<failure>Assertion failure without message - Actual: My Big Fat Greek Wedding Expected: My Big Fat Greek Funeral</failure>
</testcase>
</testsuite>"
`);
});
});
class MockStream {
constructor() {
this._output = '';
}
write(output) {
this._output += output;
}
get output() {
return this._output;
}
}