How to do custom assertions
See original GitHub issueHow would one go about adding their own, project-local assertions to qunit-dom?
With QUnit, we can say
QUnit.assert.myAssertion = function() {...}
However, to be able to do that with an object returned from QUnit.dom(…), one would have to extend a DOMAssertions object or prototype. I couldn’t seem to find where that is accessible.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Custom Assertions with AssertJ - Baeldung
Writing a custom AssertJ assertion class is pretty simple. All we need to do is to declare a class that extends AbstractAssert, add...
Read more >13 Creating Custom Assertions
Step 1: Create the Custom Assertion Class · Step 2: Create the Custom Policy File · Step 3: Create the policy-config.xml File ·...
Read more >Create Custom Assertions For Test Readability - Gleb Bahmutov
Create Custom Assertions For Test Readability. How to extend Cypress with custom assertions. Application; have.attr gotcha; Workarounds; Custom ...
Read more >Custom Assertions in Java Tests - InfoQ
Custom Assertions · Both start with a call to the isNotNull() which verifies whether the tested object is not null. · They return...
Read more >Write custom Assertions to improve your tests - Just Some Code
To write custom assertions with MSTest, write an extension method on top of the Assert class. Then, compare the expected and actual parameters ......
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 FreeTop 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
Top GitHub Comments
Thank you for your response. The problem is not that I don’t know how to write assertions. Also, the example is obviously bad, as people jump in recommending how to solve the particular example rather than what I really asked for.
The problem is that there are things I would have liked to assert on the node directly in a library- or project-specific manner, and I was baffled at the response that it’s just not supported and there are no plans to do so.
Even a generic thing like
would have been useful. But if I am the only guy who wants extensible DOM assertions I can live with qunit-dom not supporting them.
I did not intend to force the issue or come across as entitled or anything (my schedule is full as well).
Closing, I accept.
you could make a helper function
or
or you can extend
QUnit.assert
as @Turbo87 mentioni would just write both assertions but if you really want to do it in one call i recommend the helper function.