stacks of test module don't include private methodsΒ #46459
Copy link
Copy link
Closed
Labels
test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Description
Activity
Can you please provide a runnable reproduction?
I tried with this, and the stack trace includes the private methods:
import t from 'node:test'; class MyClass { pub() { this.#priv1(); } #priv1() { this.#priv2(); } #priv2() { this.pub2(); } pub2() { throw new Error('err'); } } t.test(() => { new MyClass().pub(); })
$ node test.mjs TAP version 13 # Subtest: <anonymous> not ok 1 - <anonymous> --- duration_ms: 0.693375 failureType: 'testCodeFailure' error: 'err' code: 'ERR_TEST_FAILURE' stack: |- MyClass.pub2 (file:///Users/mzasso/git/test/test.mjs:17:11) #priv2 (file:///Users/mzasso/git/test/test.mjs:13:10) #priv1 (file:///Users/mzasso/git/test/test.mjs:9:16) MyClass.pub (file:///Users/mzasso/git/test/test.mjs:5:16) TestContext.<anonymous> (file:///Users/mzasso/git/test/test.mjs:22:17) Test.runInAsyncScope (node:async_hooks:204:9) Test.run (node:internal/test_runner/test:548:25) Test.start (node:internal/test_runner/test:464:17) Function.test (node:internal/test_runner/harness:132:18) file:///Users/mzasso/git/test/test.mjs:21:3 ... 1..1 # tests 1 # pass 0 # fail 1 # cancelled 0 # skipped 0 # todo 0 # duration_ms 3.862Reacted by Moshe Atlow- addedtest_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
on Feb 1, 2023 @piranna can you provide some reproduction? Otherwise, let's close this out.
Reacted by Moshe Atlowclosing, feel free to reopen if there is a reproduction
Metadata
Metadata
Assignees
Labels
test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Version
v19.4.0
Platform
Linux AVRAST1790 5.19.0-30-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 6 15:40:20 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
test
What steps will reproduce the bug?
When running some failing code that throw an exception, the stack trace shows the private methods that the code has passed on, but when the same exception is thrown as part of one test of the new built-in
testmodule, stack traces for private methods are removed, not sure if on purpose or by an error (I think the later, since it's important info for debuging).How often does it reproduce? Is there a required condition?
Always that I run it.
What is the expected behavior?
All stack traces shown on errors thrown when running the
testmodule, including the calls to private methods.What do you see instead?
Stack traces for private method calls are missing on the stack traces.
Additional information
No response