-
Notifications
You must be signed in to change notification settings - Fork 781
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
Core: Implements QUnit.skip #652
Conversation
I can pass a value on the |
Agreed on the reporter changes. I'd also like a test covering the |
this.testName = "SKIPPED - " + this.testName; | ||
for ( method in Assert.prototype ) { | ||
this.assert[ method ] = skippedAssertion; | ||
} |
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.
Is this necessary? And if yes, would the code make more sense elsewhere with something like this.assert = new Assert( settings.skip ? null : this )
here?
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.
this is necessary to prevent assertions inside the module hooks (beforeEach/afterEach), on the skipped tests.
I'm stubbing every method defined on Assert
's prototype and I believe it's the Test
's responsibility to handle if it's a skipped one or not.
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.
I agree that properly reacting to settings.skip
is the Test's responsibility, but manually faking a dummy object similar to an Assert
but not instanceof Assert
rather than delegating the implementation seems kludgy.
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.
One alternative may be to instead short-circuit the Test#hooks
call to not retrieve any hooks if the test is marked as skip
. This seems reasonable to me but that reasonability really depends on consumer usage.
@JamesMGreene @gibson042: Implemented the reporter logging and also the suggested test. |
@@ -139,6 +152,7 @@ Test.prototype = { | |||
runLoggingCallbacks( "testDone", { | |||
name: this.testName, | |||
module: this.module, | |||
skipped: !!this.skip, |
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.
Related to qunitjs/js-reporters#4: I'm thinking we'll probably end up standardizing this to be a more generic property like status: "skipped"
. Not sure if we want to pursue that presumed direction yet in this PR or just leave this QUnit-specific for now.
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.
I think we should just proceed by leaving this as a QUnit-specific thing for now and we can update in QUnit v2.0
if we decide on a more standard format going forward in collaboration with the other testing frameworks.
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.
yes, I've preferred to keep it as it is before it's definition on the js-reporter.
skippedAssertion = function() {}; | ||
|
||
if ( settings.skip ) { | ||
this.testName = "SKIPPED - " + this.testName; |
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.
as skipped tests blocks - and respective hooks - aren't called anymore, there's no more need to fake the Assert object.
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.
follow back to #652 (comment)
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.
Excellent! skippedAssertion
can now be dropped as well.
8189558
to
9dd6a77
Compare
Thanks @gibson042 and @JamesMGreene. Fixed the code and rebased with master. |
LGTM! 👍 |
@jzaefferer @Krinkle @scottgonzalez: Any desire to review this PR further before we merge it? |
throw "Error"; | ||
}); | ||
|
||
QUnit.skip ( "no function" ); |
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.
jscs
doesn't detect the extra space here. Let's fix this and report the missing check.
Reviewed this in detail, found a few issues. Apart from that it would be good to outline what API docs need to be written or updated. Let's put that in the description of the PR. |
testName: testName, | ||
expected: 0, | ||
async: false, | ||
callback: function() {}, |
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.
This deserves a line comment, I missed it on first review.
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.
Though if we can move the default properties inside the constructor, the differences to the call in QUnit.test
should be much more obvious.
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.
I also missed it the first time through, took a second pass to find it.
We should also include the number of skipped tests in the summary atop the html reporter.
Maybe add something like
That way they're discoverable without having to scan the page manually. PHPUnit, for example, reports:
|
I think the background color of the cell should still be different for skipped tests but adding the yellow bubble is a nice additional visual treatment. I also agree about including the number of skipped tests in the summary. |
Adding the bubble along with a different background color, while not modifying the test name sounds good. Since skipped tests don't run assertions, we can't actually tell how many assertions were skipped. Mixing assertions and tests in the summary sounds like a bad idea. I'm okay with landing this without changes to the summary. |
About the bubble label: I prefer to change only the background color instead of inserting a bubble. As we are using the colors to indicate the test status and skipped is a new one. |
I like the idea to include the number of skipped tests on the summary, as long as they are not on the sum of the passed tests. |
Also logs skipped tests on testDone callback that are handled on the html reporter Fixes qunitjs#637 Fixes qunitjs#434
After talking with @jzaefferer, I'm trying a new suggestion: grey background for the skipped line with the yellow bubble. Runtime is also not inserted (there's not test to run there). Rerun link was intentionally kept. |
As we summarize only the passed and failed assertions on the reporter, I prefer to address it on another issue/PR. |
addClass( testItem, "skipped" ); | ||
skipped = document.createElement( "em" ); | ||
skipped.className = "qunit-skipped-label"; | ||
skipped.innerHTML = "SKIPPED"; |
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.
Make this "Skipped", add a CSS rule to show it uppercase. Allows themes to override that.
assert.expect( 3 ); | ||
|
||
assert.ok( testDoneContext.runtime >= 0, "logs runtime" ); | ||
assert.ok( testDoneContext.duration >= 0, "logs deprecated duration" ); |
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.
Let's remove these two assertions. We don't care about the runtime of skipped tests. Its okay to have them there, but we don't need to test for that.
@@ -102,6 +114,11 @@ Test.prototype = { | |||
hooks: function( handler ) { | |||
var hooks = []; | |||
|
|||
// hooks are also ignored on skipped tests |
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.
Uppcase first char in line comments
Reviewed everything once more, looks great to me. Would be nice to get a nod-off from @JamesMGreene or @Krinkle as well. |
Good call on applying a change to the background of the row as well. The grey and yellow look good to me: (RE: 0122c75) The ALL CAPS label text is a bit excessive though. Title Case doesn't seem appropriate either. Perhaps lowercase will fit in nicely with the overall friendly interface? |
I'd say definitely not TitleCase for the "SKIPPED" bubble. I'm fine with either all uppercase or lowercase. |
Done, lowercase "skipped" is now the default. Also other reporter can change it through CSS's text-transform |
Ref qunitjs/qunit#637 Ref qunitjs/qunit#652 Fixes #75 Closes #77
Fixes #637
Fixes #434
API issue: qunitjs/api.qunitjs.com#75