Skip to content

Test runner: errors are truncated in spec reporter when running with --test #46871

@MoLow

Description

@MoLow

Version

v19.7.0

Platform

Darwin Moshes-MBP.localdomain 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 arm64

Subsystem

Test runner

What steps will reproduce the bug?

create test file:

const test = require('node:test');

test('this should fail', () => {
  throw new Error('this should fail');
});
test('this should fail', () => {
  throw new TypeError('this should fail123123');
});

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

allwaysalways

What is the expected behavior?

when running without --test:

node --test-reporter spec a.js                                                                                                                 ✔  19.7.0  
✖ this should fail (0.749375ms)
  Error: this should fail
      at TestContext.<anonymous> (/Users/moshe/repos/node/a.js:4:9)
      at Test.runInAsyncScope (node:async_hooks:203:9)
      at Test.run (node:internal/test_runner/test:549:25)
      at Test.start (node:internal/test_runner/test:465:17)
      at test (node:internal/test_runner/harness:172:18)
      at Object.<anonymous> (/Users/moshe/repos/node/a.js:3:1)
      at Module._compile (node:internal/modules/cjs/loader:1275:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
      at Module.load (node:internal/modules/cjs/loader:1133:32)
      at Module._load (node:internal/modules/cjs/loader:972:12)

✖ this should fail (1.003875ms)
  TypeError: this should fail123123
      at TestContext.<anonymous> (/Users/moshe/repos/node/a.js:7:9)
      at Test.runInAsyncScope (node:async_hooks:203:9)
      at Test.run (node:internal/test_runner/test:549:25)
      at Test.processPendingSubtests (node:internal/test_runner/test:304:27)
      at Test.postRun (node:internal/test_runner/test:634:19)
      at Test.run (node:internal/test_runner/test:577:10)

ℹ tests 2
ℹ pass 0
ℹ fail 2
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 6.028833

What do you see instead?

when running with --test

node --test --test-reporter spec a.js                                                                                                        1 ✘  19.7.0  
▶ /Users/moshe/repos/node/a.js
  ✖ this should fail (0.773875ms)
        at TestContext.<anonymous> (/Users/moshe/repos/node/a.js:4:9)
        at Test.runInAsyncScope (node:async_hooks:203:9)
        at Test.run (node:internal/test_runner/test:549:25)
        at Test.start (node:internal/test_runner/test:465:17)
        at test (node:internal/test_runner/harness:172:18)
        at Object.<anonymous> (/Users/moshe/repos/node/a.js:3:1)
        at Module._compile (node:internal/modules/cjs/loader:1275:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
        at Module.load (node:internal/modules/cjs/loader:1133:32)
        at Module._load (node:internal/modules/cjs/loader:972:12) {
      code: 'ERR_TEST_FAILURE'
    }

  ✖ this should fail (1.427042ms)
        at TestContext.<anonymous> (/Users/moshe/repos/node/a.js:7:9)
        at Test.runInAsyncScope (node:async_hooks:203:9)
        at Test.run (node:internal/test_runner/test:549:25)
        at Test.processPendingSubtests (node:internal/test_runner/test:304:27)
        at Test.postRun (node:internal/test_runner/test:634:19)
        at Test.run (node:internal/test_runner/test:577:10) {
      code: 'ERR_TEST_FAILURE'
    }

▶ /Users/moshe/repos/node/a.js (55.624541ms)

ℹ tests 1
ℹ pass 0
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 56.438083

Additional information

No response

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