Skip to content

Test runner: spec reporter hides assert.deepStrictEqual diff when used with --test parameter #47051

@koshic

Description

@koshic

Version

v19.7.0

Platform

Darwin MOW-C02CF81MMD6T 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

With given file t.js

import { test } from "node:test";
import { deepEqual } from "node:assert/strict";

await test("deepEqual", () => {
  deepEqual({ a: 1 }, { b: 2 });
});

node --test-reporter spec t.js -> diff is present (see expected behaviour)
node --test-reporter spec --test t.js -> no diff at all

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

Output with diff like that

✖ deepEqual (6.345687ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
    {
  +   a: 1
  -   b: 2
    }
      at TestContext.<anonymous> (t.js:5:3)
      at Test.runInAsyncScope (node:async_hooks:203:9)
      at Test.run (node:internal/test_runner/test:549:25)
      at Test.start (node:internal/test_runner/test:465:17)
      at test (node:internal/test_runner/harness:172:18)
      at t.js:4:7
      at ModuleJob.run (node:internal/modules/esm/module_job:193:25) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [Object],
    expected: [Object],
    operator: 'deepStrictEqual'
  }

What do you see instead?

No diff, actual & expected values are undefined

  ✖ deepEqual (6.316001ms)
        at TestContext.<anonymous> (t.js:5:3)
        at Test.runInAsyncScope (node:async_hooks:203:9)
        at Test.run (node:internal/test_runner/test:549:25)
        at Test.start (node:internal/test_runner/test:465:17)
        at test (node:internal/test_runner/harness:172:18)
        at t.js:4:7
        at ModuleJob.run (node:internal/modules/esm/module_job:193:25) {
      generatedMessage: false,
      code: 'ERR_ASSERTION',
      actual: undefined,
      expected: undefined,
      operator: 'deepStrictEqual'
    }

Additional information

This make makes spec reporter are totally useless, because I have to re-run failed tests one by one to understand what's happened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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