Skip to content

Commit 74ea047

Browse files
committed
test: fix tap parser fails if a test logs a number
1 parent cd4f4b4 commit 74ea047

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/internal/test_runner/tap_parser.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,16 @@ class TapParser extends Transform {
644644
}
645645

646646
const planEnd = this.#next();
647-
if (planEnd?.kind !== TokenKind.NUMERIC) {
647+
if (!planEnd || planEnd.kind !== TokenKind.NUMERIC) {
648648
this.#error('Expected a plan end count');
649+
const node = {
650+
kind: TokenKind.UNKNOWN,
651+
node: {
652+
value: this.#currentChunkAsString,
653+
},
654+
};
655+
656+
return node;
649657
}
650658

651659
const plan = {

test/parallel/test-runner-tap-parser-stream.js

+22
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ const cases = [
1717
},
1818
],
1919
},
20+
{
21+
input: '123',
22+
expected: [
23+
{
24+
kind: 'Unknown',
25+
node: { value: '123' },
26+
nesting: 0,
27+
lexeme: '123',
28+
},
29+
],
30+
},
31+
{
32+
input: '# 123',
33+
expected: [
34+
{
35+
kind: 'Comment',
36+
node: { comment: '123' },
37+
nesting: 0,
38+
lexeme: '# 123',
39+
},
40+
],
41+
},
2042
{
2143
input: 'invalid tap',
2244
expected: [

0 commit comments

Comments
 (0)