Using power-assert in jest prints the output twice
See original GitHub issue
This is the test case demonstrating the issue above (contrived test to show duplicate output):
test('Test retrieval of TagList props object', () => {
const props = getDefaultTagListProps();
assert(props);
expect(props).toMatchSnapshot();
let x = 'abc';
let y = 'zyz';
assert(x === y);
});
jest: 20.0.4 babel: 6.24.1 babel-preset-power-assert: 1.0.0 power-assert: 1.4.4
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Using power-assert in jest prints the output twice - - Bountysource
This is the test case demonstrating the issue above (contrived test to show duplicate output): test('Test retrieval of TagList props object', ...
Read more >Why Groovy's power assert prints failure messages twice?
Using a method like the ok() below verifies this "theory" as well as giving a possible solution to the double message issue:
Read more >Multiple assertions are fine in a unit test - Hacker News
I like to use Jest's toMatchObject to combine multiple assertions in a single assertion. If the assertion fails, the full object on both ......
Read more >Power-assert: Power Assert in JavaScript - Morioh
is an implementation of "Power Assert" concept in JavaScript. provides descriptive assertion messages through standard assert interface. No API is the best API....
Read more >ava - npm.io
Only works with test.cb() . t.log(...values). Log values contextually alongside the test result instead of immediately printing them ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jmquigley Thank you for creating repro case repository!
While I’m investigating the issue, I found that stack recreation introduced in #85 is the cause of showing same diagram twice. Reporter output from Node6 and Node8 differs.
In #85, I added power-assert diagram to
err.stack
too. ThereforeAssertionError
thrown by power-assert have same diagram inerr.message
anderr.stack
, since most reporters (e.g. Mocha) useerr.message
but vanilla Node8 useserr.stack
for reporting.It seems that Jest reports both
err.message
anderr.stack
so you saw the same diagram twice.A possible solution here is to create custom reporter for Jest. I’m going to create the one.
@jmquigley As digging deeper, I’ve found some hints.
AssertionError#message
but extract messages fromError#stack
.