Skip to content

diagnostic not correct for nested tests #207

@hildjj

Description

@hildjj

Given this test:

import test from "node:test";

test("root", t => {
  t.diagnostic("one");
  t.test("child", t => {
    t.diagnostic("two");
  });
  t.diagnostic("three");
});

I expect to get this result:

{
  "tests": [
    {
      "name": "root",
      "file": "dm.test.js",
      "tests": [
        {
          "name": "child",
          "file": "dm.test.js",
          "tests": [],
          "duration": 0.315334,
          "skip": false,
          "todo": false,
          "diagnostic": "two"
        }
      ],
      "duration": 0.731083,
      "skip": false,
      "todo": false,
      "diagnostic": "one\nthree\n"
    }
  ],
  "duration": 50.446458
}

But instead I get this:

{
  "tests": [
    {
      "name": "root",
      "file": "dm.test.js",
      "tests": [
        {
          "name": "child",
          "file": "dm.test.js",
          "tests": [],
          "duration": 0.315334,
          "skip": false,
          "todo": false
        }
      ],
      "duration": 0.731083,
      "skip": false,
      "todo": false,
      "diagnostic": "two\n"
    }
  ],
  "duration": 50.446458
}

Note that the diagnostic "two" is reported on the root test, the child test has no diagnostic, and the diagnostics "one" and "three" are lost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions