Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stacks of test module don't include private methods #46459

Closed
piranna opened this issue Feb 1, 2023 · 3 comments
Closed

stacks of test module don't include private methods #46459

piranna opened this issue Feb 1, 2023 · 3 comments
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@piranna
Copy link
Contributor

piranna commented Feb 1, 2023

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 test module, 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 test module, 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

@targos
Copy link
Member

targos commented Feb 1, 2023

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.862

@targos targos added the test_runner Issues and PRs related to the test runner subsystem. label Feb 1, 2023
@cjihrig
Copy link
Contributor

cjihrig commented Feb 15, 2023

@piranna can you provide some reproduction? Otherwise, let's close this out.

@MoLow
Copy link
Member

MoLow commented Feb 18, 2023

closing, feel free to reopen if there is a reproduction

@MoLow MoLow closed this as completed Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants