-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Support .only for all files #556
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ Api.prototype._reset = function () { | |
| this.failCount = 0; | ||
| this.fileCount = 0; | ||
| this.testCount = 0; | ||
| this.hasExclusive = false; | ||
| this.errors = []; | ||
| this.stats = []; | ||
| this.tests = []; | ||
|
|
@@ -103,6 +104,15 @@ Api.prototype._handleTeardown = function (data) { | |
| }; | ||
|
|
||
| Api.prototype._handleStats = function (stats) { | ||
| if (this.hasExclusive && !stats.hasExclusive) { | ||
| return; | ||
| } | ||
|
|
||
| if (!this.hasExclusive && stats.hasExclusive) { | ||
| this.hasExclusive = true; | ||
| this.testCount = 0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly why is this being reset? Because we've already counted tests we're now not going to run, right? I appreciate
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, same logic. Again, not too keen on it but couldn't think of a more elegant solution. Suggestions welcome!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nah it's good enough as is, just requires some extra thinking. |
||
| } | ||
|
|
||
| this.testCount += stats.testCount; | ||
| }; | ||
|
|
||
|
|
@@ -198,9 +208,12 @@ Api.prototype.run = function (files) { | |
| self.emit('ready'); | ||
|
|
||
| var method = self.options.serial ? 'mapSeries' : 'map'; | ||
| var options = { | ||
| runOnlyExclusive: self.hasExclusive | ||
| }; | ||
|
|
||
| resolve(Promise[method](files, function (file, index) { | ||
| return tests[index].run().catch(function (err) { | ||
| return tests[index].run(options).catch(function (err) { | ||
| // The test failed catastrophically. Flag it up as an | ||
| // exception, then return an empty result. Other tests may | ||
| // continue to run. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import test from '../../'; | ||
|
|
||
| test.only(t => { | ||
| t.pass(); | ||
| }); | ||
|
|
||
| test(t => { | ||
| t.fail(); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import test from '../../'; | ||
|
|
||
| test.only(t => { | ||
| t.pass(); | ||
| }); |
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.
Could you add a comment as to why the function is returning here? It's because if we're running exclusive tests, but the test file does not include exclusive tests, then we don't want those tests to be counted, right?
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.
Correct, although I'm not super keen on just dropping this info on the floor. I just went for consistency with how non-exclusive tests are dropped within
test-collection. I'll add a comment to that effect.That said, I would favor changing the reporting completely as suggested by #471.