-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTAPParser.test.js
More file actions
78 lines (61 loc) · 2.04 KB
/
Copy pathTAPParser.test.js
File metadata and controls
78 lines (61 loc) · 2.04 KB
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
import { describe, it } from "node:test";
import assert from "node:assert";
import { TAPParser } from "./TAPParser.js";
describe("TAPParser", () => {
const parser = new TAPParser();
it("should identify TAP format", () => {
const content = `TAP version 13
1..3
ok 1 - test passed
not ok 2 - test failed
ok 3 - test passed # SKIP`;
assert.strictEqual(parser.canParse("test.tap", content), true);
});
it("keeps auto-pattern path detection synchronized", () => {
const filePath = "reports/results.tap";
const content = `TAP version 13
1..1
ok 1 - sample`;
assert.ok(parser.matchesAutoPatterns(filePath));
assert.ok(parser.canParse(filePath, content));
});
it("should parse basic TAP output", () => {
const content = `TAP version 13
1..3
ok 1 - test one
not ok 2 - test two
ok 3 - test three`;
const result = parser.parse(content, "test.tap");
verifyBasicCounts(result, 3, 2, 1);
});
it("should parse skipped tests", () => {
const content = `1..2
ok 1 - test one
ok 2 - test two # SKIP not implemented`;
const result = parser.parse(content, "test.tap");
assert.strictEqual(result.getTotalTests(), 2);
assert.strictEqual(result.getPassedCount(), 1);
assert.strictEqual(result.getSkippedCount(), 1);
const skippedTest = result.getSkippedTests()[0];
assert.strictEqual(skippedTest.message, "not implemented");
});
it("should parse TODO tests", () => {
const content = `1..1
not ok 1 - test one # TODO fix later`;
const result = parser.parse(content, "test.tap");
assert.strictEqual(result.getSkippedCount(), 1);
assert.ok(result.getSkippedTests()[0].message.includes("TODO"));
});
it("should handle tests without numbers", () => {
const content = `ok - first test
ok - second test
not ok - third test`;
const result = parser.parse(content, "test.tap");
verifyBasicCounts(result, 3, 2, 1);
});
});
function verifyBasicCounts(result, total, passed, failed) {
assert.strictEqual(result.getTotalTests(), total);
assert.strictEqual(result.getPassedCount(), passed);
assert.strictEqual(result.getFailedCount(), failed);
}