-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Less API using power-assert #46
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
27f08ed
Add power-assert to enhance test output
uiur 0780d2d
Add enhanced output for t.assert()
uiur 96beedc
Update power-assert-renderers
uiur 96e81be
Remove unneccessary expressions
uiur 603ef01
Add comment for workaround
uiur dfb0c45
Add patterns for power-assert
uiur 8087faa
Add test for power-assert output
uiur d7cf4bd
Update empower
uiur 8673535
Fix wrong indent
uiur 8f8f1fb
Move enhanceAssert() into ./lib/enhance-assert.js
uiur 5a637c2
Remove a unnecessary line
uiur bd3a06e
Use t.not()
uiur b8fc55d
Test that it renders a diagram output
uiur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = enhanceAssert; | ||
|
||
module.exports.PATTERNS = [ | ||
't.ok(value, [message])', | ||
't.notOk(value, [message])', | ||
't.true(value, [message])', | ||
't.false(value, [message])', | ||
't.is(value, expected, [message])', | ||
't.not(value, expected, [message])', | ||
't.same(value, expected, [message])', | ||
't.notSame(value, expected, [message])', | ||
't.regexTest(regex, contents, [message])' | ||
]; | ||
|
||
function enhanceAssert(assert) { | ||
var empower = require('empower'); | ||
var powerAssertFormatter = require('power-assert-formatter'); | ||
var powerAssertRenderers = require('power-assert-renderers'); | ||
|
||
empower(assert, | ||
powerAssertFormatter({ | ||
renderers: [ | ||
powerAssertRenderers.AssertionRenderer, | ||
powerAssertRenderers.SuccinctRenderer | ||
] | ||
}), | ||
{ | ||
destructive: true, | ||
modifyMessageOnRethrow: true, | ||
saveContextOnRethrow: false, | ||
patterns: module.exports.PATTERNS | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import test from '../../'; | ||
|
||
test(t => { | ||
const a = 'foo'; | ||
|
||
t.ok(a === 'bar'); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twada Is there anything you can do in
power-assert
to make this unnecessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this workaround is necessary for now (
_capt
and_expr
methods are needed at the top level).To make them look less messy, I'll introduce small helper method like
(looking for a better name though)