镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

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.

Activity

  1. MoLow commented on Mar 12, 2023

    @MoLow
    Member

    Duplicate of: #46871

  2. MoLow commented on Mar 12, 2023

    @MoLow
    Member

    fixed by c7e6a0c

  3. added
    test_runnerIssues and PRs related to the test runner subsystem.
    on Mar 12, 2023
  4. koshic commented on Mar 12, 2023

    @koshic
    Author

    @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'
    
  5. reopened this on Mar 12, 2023
  6. MoLow commented on Mar 12, 2023

    @MoLow
    Member

    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
    
  7. koshic commented on Mar 12, 2023

    @koshic
    Author

    @MoLow thank you!

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

    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