Sitelet https://github.com/nodejs/node/issues/45641
Skip to content

[node:test] Incorrect SuiteContext description #45641

Description

@Semigradsky

Affected url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2Fs)

https://nodejs.org/docs/latest-v18.x/api/test.html#describename-options-fn

Description of the problem

Docs said that tha callback function in describe:

declaring all subtests and subsuites. The first argument to this function is a SuiteContext object.

But in fact SuiteContext is not the first argument. SuiteContext is this context:

import { describe } from 'node:test'

describe(function(foo) {
    console.log('First argument: ', foo)
    console.log('this: ', this)
})

> First argument:  []
> this:  { signal: AbortSignal { aborted: false }, name: '<anonymous>' }

Activity

  1. added
    docIssues and PRs related to Node.js documentation.
    on Nov 27, 2022
  2. Semigradsky commented on Nov 27, 2022

    @Semigradsky
    ContributorAuthor

    But TestContext is the first argument:

    import { test } from 'node:test'
    
    test(function(foo) {
        console.log('First argument: ', foo)
        console.log('this: ', this)
    })
    
    > First argument:  TestContext {}
    > this:  TestContext {}
  3. cjihrig commented on Nov 27, 2022

    @cjihrig
    Contributor

    @MoLow it looks like the SuiteContext language was added in 389b7e1. It doesn't look like SuiteContext exists in the code though. Should all references to SuiteContext be replaced with TestContext?

  4. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on Nov 27, 2022
  5. MoLow commented on Nov 28, 2022

    @MoLow
    Member

    @cjihrig it is simply generated as an object literal

    getRunArgs() {
    return { ctx: { signal: this.signal, name: this.name }, args: [] };
    }

  6. cjihrig commented on Nov 29, 2022

    @cjihrig
    Contributor

    I think we should either change the docs to remove the use of SuiteContext since it doesn't really exist as a class or update the code to make it an actual class. I think updating the code would be easiest in this case.

  7. added
    diag-agendaIssues and PRs to discuss during Diagnostics Working Group meetings.
    good first issueIssues that are suitable for first-time contributors.
    and removed
    docIssues and PRs related to Node.js documentation.
    diag-agendaIssues and PRs to discuss during Diagnostics Working Group meetings.
    on Nov 29, 2022
  8. added a commit that references this issue on Nov 30, 2022
  9. debadree25 commented on Nov 30, 2022

    @debadree25
    Contributor

    Have added PR for the same @cjihrig

  10. added a commit that references this issue on Dec 2, 2022
  11. added a commit that references this issue on Dec 12, 2022
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

    good first issueIssues that are suitable for first-time contributors.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