- 
                Notifications
    You must be signed in to change notification settings 
- Fork 30.5k
[node:test] add setup and watch for RunOptions #66064
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
Conversation
| @koh110 Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PRCode ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
 All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. InactiveThis PR has been inactive for 11 days — please merge or say something if there's a problem, otherwise it will be closed! Diagnostic Information: What the bot saw about this PR{
  "type": "info",
  "now": "-",
  "pr_number": 66064,
  "author": "koh110",
  "headCommitOid": "31034ca619357d13e9292010acaa0f0409803d48",
  "mergeBaseOid": "77b183c95be2dc99f7399c54c4860f312a456ca8",
  "lastPushDate": "2023-07-14T08:41:49.000Z",
  "lastActivityDate": "2023-08-05T10:14:10.000Z",
  "mergeOfferDate": "2023-07-24T19:26:16.000Z",
  "mergeRequestDate": "2023-08-04T01:06:58.000Z",
  "mergeRequestUser": "koh110",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Critical",
  "pkgInfo": [
    {
      "name": "node",
      "kind": "edit",
      "files": [
        {
          "path": "types/node/test.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/test/test.ts",
          "kind": "test"
        },
        {
          "path": "types/node/ts4.8/test.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/ts4.8/test/test.ts",
          "kind": "test"
        },
        {
          "path": "types/node/v18/test.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/node/v18/test/test.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "Microsoft",
        "DefinitelyTyped",
        "jkomyno",
        "alvis",
        "r3nya",
        "btoueg",
        "smac89",
        "touffy",
        "DeividasBakanas",
        "eyqs",
        "Hannes-Magnusson-CK",
        "hoo29",
        "kjin",
        "ajafff",
        "islishude",
        "mwiktorczyk",
        "mohsen1",
        "n-e",
        "galkin",
        "parambirs",
        "eps1lon",
        "SimonSchick",
        "ThomasdenH",
        "WilcoBakker",
        "wwwy3y3",
        "samuela",
        "kuehlein",
        "bhongy",
        "chyzwar",
        "trivikr",
        "yoursunny",
        "qwelias",
        "ExE-Boss",
        "peterblazejewicz",
        "addaleax",
        "victorperin",
        "ZYSzys",
        "NodeJS",
        "LinusU",
        "wafuwafu13",
        "mcollina",
        "Semigradsky"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "rbuckton",
      "date": "2023-07-24T19:25:31.000Z",
      "isMaintainer": true
    },
    {
      "type": "stale",
      "reviewer": "Semigradsky",
      "date": "2023-07-17T08:41:33.000Z",
      "abbrOid": "5a92bf3"
    }
  ],
  "mainBotCommentID": 1635514806,
  "ciResult": "pass"
} | 
| 🔔 @microsoft @DefinitelyTyped @jkomyno @alvis @r3nya @btoueg @smac89 @Touffy @DeividasBakanas @eyqs @Hannes-Magnusson-CK @hoo29 @kjin @ajafff @islishude @mwiktorczyk @mohsen1 @n-e @galkin @parambirs @eps1lon @SimonSchick @ThomasdenH @WilcoBakker @wwwy3y3 @samuela @kuehlein @bhongy @chyzwar @trivikr @yoursunny @qwelias @ExE-Boss @peterblazejewicz @addaleax @victorperin @ZYSzys @nodejs @LinusU @wafuwafu13 @mcollina @Semigradsky — please review this PR in the next few days. Be sure to explicitly select  | 
| @koh110 The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. | 
        
          
                types/node/test.d.ts
              
                Outdated
          
        
      | /** | ||
| * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run. | ||
| */ | ||
| setup?: (root: unknown) => void | Promise<void>; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup?: (testsStream: TestsStream) => void | Promise<void>;From doc:
A function that accepts the
TestsStreaminstance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and it seems that the implementation is not TestStream but Test class.
https://github.com/nodejs/node/blob/v20.4.0/lib/internal/test_runner/harness.js#L29-L31
https://github.com/nodejs/node/blob/v20.4.0/lib/internal/test_runner/test.js#L165-L192
https://github.com/nodejs/node/blob/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,Should I create Test class and all property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be a bug, I have created nodejs/node#48809
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your creating issue.
I have modified this PR to match the current implementation.
But should I wait until the issue is resolved?
| Also please add changes to  | 
| @Semigradsky Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? | 
| @koh110: Everything looks good here. I am ready to merge this PR (at 31034ca) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying: 
 and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@microsoft, @DefinitelyTyped, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @n-e, @galkin, @parambirs, @eps1lon, @SimonSchick, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @ZYSzys, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky: you can do this too.) | 
| Re-ping @koh110 / @microsoft, @DefinitelyTyped, @jkomyno, @alvis, @r3nya, @btoueg, @smac89, @Touffy, @DeividasBakanas, @eyqs, @Hannes-Magnusson-CK, @hoo29, @kjin, @ajafff, @islishude, @mwiktorczyk, @mohsen1, @n-e, @galkin, @parambirs, @eps1lon, @SimonSchick, @ThomasdenH, @WilcoBakker, @wwwy3y3, @samuela, @kuehlein, @bhongy, @chyzwar, @trivikr, @yoursunny, @qwelias, @ExE-Boss, @peterblazejewicz, @addaleax, @victorperin, @ZYSzys, @nodejs, @LinusU, @wafuwafu13, @mcollina, @Semigradsky: This PR has been ready to merge for over a week, and I haven't seen any requests to merge it. I will close it on Aug 23rd (in three weeks) if this doesn't happen. (If there's no reason to avoid merging it, please do so. Otherwise, if it shouldn't be merged or if it needs more time, please close it or turn it into a draft.) | 
| Ready to merge | 
| note: edited comment to kick the bot str matcher | 
setupandwatchoptionsThe implementation of the setup function includes arguments, but the Node.js documentation does not provide any description of the argument types.
https://nodejs.org/docs/latest-v20.x/api/test.html#runoptions
https://github.com/nodejs/node/blob/v20.4.0/lib/internal/test_runner/runner.js#L510
https://github.com/nodejs/node/blob/v20.4.0/lib/internal/test_runner/harness.js#L29-L31
Please fill in this template.
npm test <package to test>.If changing an existing definition: