Skip to content
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

keep hierarchy for skipped suites w/o a callback #3242

Merged
merged 1 commit into from Mar 18, 2018

Conversation

outsideris
Copy link
Member

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions.

Description of the Change

As my local test for #3184, describe.skip without a callback couldn't keep a hierarchy of suites.

For Instance.

var assert = require('assert');

describe("Some tests", function(){
  describe.skip("Some disabled test", function() {});
});

describe("Some other tests", function(){
  it("should still pass", function(){
    assert.equal(1,1);
  });
});

is show below output.

  Some other tests
    ✓ should still pass


  1 passing (5ms)

It is correct. But when omit a callback in describe.skip.

var assert = require('assert');

describe("Some tests", function(){
  describe.skip("Some disabled test");
});

describe("Some other tests", function(){
  it("should still pass", function(){
    assert.equal(1,1);
  });
});

A hierarchy of the suites is wrong like below.

  Some tests
    Some other tests
      ✓ should still pass


  1 passing (5ms)

So, this PR add suites.shift(); for a skipped suite w/o a callback.

Alternate Designs

I'm not sure.

Why should this be in core?

Some test can be skipped not intentionally.

Benefits

Skipped suites don't make side effect for other tests.

Possible Drawbacks

I'm not sure.

Applicable issues

#3184

I don't agree #2014 is related to this issue.

@coveralls
Copy link

coveralls commented Feb 14, 2018

Coverage Status

Coverage increased (+0.05%) to 90.0% when pulling b844006 on outsideris:issue-3184 into ec8901a on mochajs:master.

Copy link
Member

@boneskull boneskull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks. I think this looks OK, but please see a couple comments I have.

I'll probably add more coverage around this after it's merged.

@@ -113,6 +113,8 @@ module.exports = function (suites, context, mocha) {
suites.shift();
} else if (typeof opts.fn === 'undefined' && !suite.pending) {
throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
} else if (typeof opts.fn === 'undefined' && suite.pending) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please simplify

} else if (!opts.fn && suite.pending) {

describe('a suite', function(){
describe.skip('skipped suite 1');
describe.skip('skipped suite 2');
describe('anothor suite', function(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: "another"

@boneskull boneskull added type: bug a defect, confirmed by a maintainer semver-patch implementation requires increase of "patch" version number; "bug fixes" labels Feb 28, 2018
@outsideris
Copy link
Member Author

Thank you for the feedback.
I updated it and rebase onto master branch.

@outsideris outsideris added status: needs review a maintainer should (re-)review this pull request and removed status: needs review a maintainer should (re-)review this pull request labels Mar 16, 2018
@boneskull
Copy link
Member

@outsideris Thanks!

@boneskull boneskull merged commit 0060884 into mochajs:master Mar 18, 2018
@boneskull boneskull added this to the next milestone Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch implementation requires increase of "patch" version number; "bug fixes" type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants