Extend Assert#pushResult to receive a custom diff value
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4k
- Forks
- 773
- PR merge metrics
- No merged PRs in 30d
Description
As requested by @wycats, it would be good to extend Assert#pushResult to receive a custom diff value, where it does not replace the default QUnit.diff (still useful for other assertions) but it prints a customized diff value.
Examples:
// Using default diff
QUnit.assert.prototype.customAssertion1 = function(actual, expected, result = actual == expected) {
return this.pushResult({result, actual, expected});
};
// Using custom diff
QUnit.assert.prototype.customAssertion2 = function(actual, expected, result = actual == expected) {
return this.pushResult({
result,
diff: lineDiff(actual, expected)
});
};
If diff is given, QUnit should get its value and ignore calling the default QUnit.diff.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Assert#pushResult and trace how it currently obtains the default QUnit.diff value. Confirm how a supplied diff should take precedence while leaving the default available to other assertions, then add coverage for both the default and custom cases using the examples in the issue as the completion criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100