Skip to content

test_runner: test object is incorrectly passed to setup() #48809

Description

@Semigradsky

Affected URL(s)

https://nodejs.org/docs/latest-v20.x/api/test.html#runoptions

Description of the problem

By doc:

options.setup - A function that accepts the TestsStream instance

but in fact that is not TestStream
nodejs/node@v20.4.0/lib/internal/test_runner/harness.js#L29-L31
nodejs/node@v20.4.0/lib/internal/test_runner/test.js#L165-L192
nodejs/node@v20.4.0/lib/internal/test_runner/tests_stream.js#L10

const stream = run({
  files: files,
  concurrency: true,
  setup: function (root) {
    console.log('setup', root)
  }
})
setup <ref *1> Test {
  concurrency: 9,
  nesting: 0,
  only: false,
  reporter: TestsStream {
    _readableState: ReadableState {
      objectMode: true,
      highWaterMark: 16,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: null,
      ended: false,
      endEmitted: false,
      reading: false,

Found in DefinitelyTyped/DefinitelyTyped#66064

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    on Jul 17, 2023
  2. removed
    docIssues and PRs related to Node.js documentation.
    on Aug 2, 2023
  3. cjihrig commented on Aug 2, 2023

    @cjihrig
    Contributor

    Thanks for reporting. I changed this in 4e3bc06, but this is a bug. I have removed the doc label because this should be fixed in the code. We should not expose any test objects to userland code.

  4. changed the title [-][node:test] Incorrect description for `setup` option in `run`[/-] [+]test_runner: test object is incorrectly passed to setup()[/+] on Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.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