Skip to content

Tap parser fails if a test logs a number #46048

Closed
@connor4312

Description

@connor4312

Version

v19.3.0

Platform

Linux Helios 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

test_runner

What steps will reproduce the bug?

Have a test file containing

const { it } = require("node:test");

it("hello world", async () => {
  console.log(1234);
})

How often does it reproduce? Is there a required condition?

100% reproduction

What is the expected behavior?

The test passes when running node --test

What do you see instead?

TAP version 13
# Subtest: /home/connor/Github/nodejs-testing/example/basic/b.test.js
not ok 1 - /home/connor/Github/nodejs-testing/example/basic/b.test.js
  ---
  duration_ms: 41.664198
  failureType: 'uncaughtException'
  error: "Cannot read properties of undefined (reading 'value')"
  code: 'ERR_TEST_FAILURE'
  stack: |-
    #Plan (node:internal/test_runner/tap_parser:653:20)
    #TAPDocument (node:internal/test_runner/tap_parser:552:28)
    #parseChunk (node:internal/test_runner/tap_parser:274:35)
    #parseTokens (node:internal/test_runner/tap_parser:249:23)
    TapParser.parse (node:internal/test_runner/tap_parser:105:24)
    TapParser._transform (node:internal/test_runner/tap_parser:187:10)
    Transform._write (node:internal/streams/transform:175:8)
    writeOrBuffer (node:internal/streams/writable:392:12)
    _write (node:internal/streams/writable:333:10)
    Writable.write (node:internal/streams/writable:337:10)
  ...
1..1
# tests 1
# pass 0
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 46.015529

Additional information

This happens for any numberic value, so console.log('1234') will produce the same result

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions