Skip to content
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

Test runner: spec reporter abridges diff on deepEqual / deepStrictEqual assertion failure #52596

Closed
danburzo opened this issue Apr 19, 2024 · 4 comments
Labels
assert Issues and PRs related to the assert subsystem. test_runner Issues and PRs related to the test runner subsystem.

Comments

@danburzo
Copy link

danburzo commented Apr 19, 2024

Version

v21.7.3

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

A failing deepEqual or deepStrictEqual assertion in a test, when using the spec test reporter.

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

No response

What is the expected behavior? Why is that the expected behavior?

The full diff, or at least a larger print depth, of the actual/expected objects helps debug the failing tests.

What do you see instead?

$> node --test 'test/**/*.test.js'

  AssertionError [ERR_ASSERTION]: parse: /* A comment */ a
      at <project-path>//test/testcases.test.js:34:14
      at Array.forEach (<anonymous>)
      at test.objectPrintDepth (<project-path>/test/testcases.test.js:20:45)
      at async Test.run (node:internal/test_runner/test:640:9)
      at async startSubtest (node:internal/test_runner/harness:218:3) {
    generatedMessage: false,
    code: 'ERR_ASSERTION',
    actual: { type: 'SelectorList', selectors: [ [Object] ] },
    expected: { type: 'SelectorList', selectors: [ [Object] ] },
    operator: 'deepStrictEqual'
  }

Additional information

Related to: #47051

@VoltrexKeyva VoltrexKeyva added assert Issues and PRs related to the assert subsystem. test_runner Issues and PRs related to the test runner subsystem. labels Apr 19, 2024
@danburzo
Copy link
Author

I narrowed it down to using the message argument in assert.deepEqual(). My tests were migrated from tape and all had the custom message. I was not aware the spec reporter prints the diff as the default message, and a custom message suppresses it.

@cjihrig
Copy link
Contributor

cjihrig commented Jan 6, 2025

@puskin94 by any chance do you know if this issue is still present, or if it was fixed by your work in #54759?

@puskin94
Copy link
Contributor

puskin94 commented Jan 6, 2025

@cjihrig should definitely have been fixed by #54759 .
Just tested on main and working fine!

@cjihrig
Copy link
Contributor

cjihrig commented Jan 6, 2025

Thanks for checking! I'll go ahead and close this then.

@cjihrig cjihrig closed this as completed Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants