Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
koshic opened this issue Mar 12, 2023 · 5 comments
Labels
test_runner Issues and PRs related to the test runner subsystem.

Comments

@koshic
Copy link

koshic commented Mar 12, 2023

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.

@MoLow
Copy link
Member

MoLow commented Mar 12, 2023

Duplicate of: #46871

@MoLow
Copy link
Member

MoLow commented Mar 12, 2023

fixed by c7e6a0c

@MoLow MoLow closed this as completed Mar 12, 2023
@MoLow MoLow added the test_runner Issues and PRs related to the test runner subsystem. label Mar 12, 2023
@koshic
Copy link
Author

koshic commented Mar 12, 2023

@MoLow I don't think that's fixed (quick assumption, can't download nightly right now): this issue related only to spec reporter, not tap.

As you can see, there are no issue with expected / actual values before that fix, only error name was missed:
image

Also, node --test-reporter tap --test t.js produces valid output, so there is a specific issue of spec reporter:

    # Subtest: deepEqual
    not ok 1 - deepEqual
      ---
      duration_ms: 6.299085
      failureType: 'testCodeFailure'
      error: |-
        Expected values to be strictly deep-equal:
        + actual - expected
        
          {
        +   a: 1
        -   b: 2
          }
      code: 'ERR_ASSERTION'
      operator: 'deepStrictEqual'

@MoLow MoLow reopened this Mar 12, 2023
@MoLow
Copy link
Member

MoLow commented Mar 12, 2023

I confirmed again, both worked on the main branch:

 ./node --test-reporter spec a.mjs                                                                                                                                        1 ✘ 
✖ deepEqual (1.964041ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
    {
  +   a: 1
  -   b: 2
    }
      at TestContext.<anonymous> (file:///Users/moshe/repos/node/a.mjs:5:3)
      at Test.runInAsyncScope (node:async_hooks:206:9)
      at Test.run (node:internal/test_runner/test:547:25)
      at Test.start (node:internal/test_runner/test:463:17)
      at startSubtest (node:internal/test_runner/harness:192:17)
      at async file:///Users/moshe/repos/node/a.mjs:4:1 {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [Object],
    expected: [Object],
    operator: 'deepStrictEqual'
  }

ℹ tests 1
ℹ pass 0
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 5.899916
./node --test --test-reporter spec a.mjs                                                                                                                                 9 ✘ 
✖ deepEqual (2.09675ms)
  AssertionError: Expected values to be strictly deep-equal:
  + actual - expected
  
    {
  +   a: 1
  -   b: 2
    }
      at TestContext.<anonymous> (file:///Users/moshe/repos/node/a.mjs:5:3)
      at Test.runInAsyncScope (node:async_hooks:206:9)
      at Test.run (node:internal/test_runner/test:547:25)
      at Test.start (node:internal/test_runner/test:463:17)
      at startSubtest (node:internal/test_runner/harness:192:17)
      at async file:///Users/moshe/repos/node/a.mjs:4:1 {
    generatedMessage: false,
    code: 'ERR_ASSERTION',
    actual: undefined,
    expected: undefined,
    operator: 'deepStrictEqual'
  }

ℹ tests 1
ℹ pass 0
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 91.159458

@MoLow MoLow closed this as completed Mar 12, 2023
@koshic
Copy link
Author

koshic commented Mar 12, 2023

@MoLow thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants