Docs: Really, use `t` for assertions
See original GitHub issueI just tried to covert a project that’s tested with tape over to using AVA instead. The tests all follow this kind of format:
test('function-a', (assert) => {
assert.plan(1);
assert.is(
functionA(),
resultB,
'function a should return result b'
);
});
They seem to run just fine under AVA, but the assertion messages don’t show up when I create a failing test case, just the test messages.
Is there a way to report on the assertion messages? Or is the best practice just to wrap every one of these assertions in its own test
block? (In which case, why do the assertions accept optional message parameters?
Am I missing something stupid?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Assertions Reference | GoogleTest
Assertions Reference. This page lists the assertion macros provided by GoogleTest for verifying code behavior. To use them, include the header gtest/gtest.h ...
Read more >Programming With Assertions - Oracle Help Center
An assertion is a statement in the Java TM programming language that enables you to test your assumptions about your program. For example,...
Read more >Type Assertions - Sorbet
There are five ways to assert the types of expressions in Sorbet: ... See Blocks, Procs, and Lambda Types for more real-world usage...
Read more >Assertions | Cypress Documentation
They don't actually do anything, but they enable you to write clear, english sentences.
Read more >How to write and report assertions in tests - Pytest
pytest allows you to use the standard Python assert for verifying expectations and values in Python tests. For example, you can write the...
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
I had this exact same issue. I guess it’s worth a note in the readme, perhaps under
FAQ
.Why is the power-assert information not shown?
Yes, yes it is. This is a byproduct of the way
power-assert
works. It uses a pattern matching scheme that makes it easier for implementors to wrap any assertion library withpower-assert
goodness without having to understand the ES AST at all (which is super awesome). That said, the AVA team certainly has members capable of creating a more robust matcher that would detect your use of a different variable name, so ifpower-assert
exposed an “advanced” API, we could certainly leverage it to provide a more user friendly experience.See https://github.com/power-assert-js/babel-plugin-espower/issues/18.
It would be non-trivial, but something worth doing.