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

.only() no longer works with nested describe()s in Mocha 3.0.0 #2406

Closed
adamjmurray opened this issue Aug 1, 2016 · 2 comments
Closed

.only() no longer works with nested describe()s in Mocha 3.0.0 #2406

adamjmurray opened this issue Aug 1, 2016 · 2 comments

Comments

@adamjmurray
Copy link

I was excited to see improvements to .only() in the Mocha 3.0.0 changelog. It's mostly working well, but I found a regression. Consider the following test file with nested describe()s:

var assert = require('assert');

describe('Array', function() {

  describe('.push()', function() {

    it('appends a value to the end of the array', function() {
      var array = [1];
      array.push(2);
      assert.deepEqual(array, [1, 2]);
    });

    it('can append more than one value to the end of the array', function() {
      var array = [1];
      array.push(2, 3);
      assert.deepEqual(array, [1, 2, 3]);
    });
  });

  describe('.reverse()', function() {

    it('reverses a non-empty array', function() {
      assert.deepEqual([1, 2, 3].reverse(), [3, 2, 1]);
    });

    it('does nothing to an empty array', function() {
      assert.deepEqual([].reverse(), []);
    });
  });
});

In previous versions of mocha, you could add a .only() to one of the inner describe()s and it would do what you expect. For example, if I changed that file to look like:

  describe.only('.push()', function() {

It should run 2 tests. That's the way previous versions of Mocha behaved. It's a very useful behavior that my team uses every day.

In Mocha 3.0.0 it runs 0 tests.

A few other notes:

  • .only() on the top-most describe() in a file works fine
  • changing describe() to context() doesn't affect the behavior (same issue with context())
@boneskull
Copy link
Contributor

I was worried about this, but unfortunately didn't get enough review or help with the code in question before it went out.

boneskull added a commit that referenced this issue Aug 4, 2016
@boneskull
Copy link
Contributor

This is published as v3.0.1; thanks again @not-an-aardvark

helderroem added a commit to helderroem/mocha that referenced this issue Aug 7, 2016
* 'master' of github.com:mochajs/mocha: (79 commits)
  Release v3.0.1
  update CHANGELOG.md; rebuild [ci skip]
  fix nested describe.only suites; closes mochajs#2406
  update date in CHANGELOG.md [ci skip]
  Release v3.0.0
  rebuild mocha.js
  fix bad merge of karma.conf.js
  add note about spec reporter to CHANGELOG.md [ci skip]
  fixed typo in mocha.css introduced by 185c0d9 [ci skip]
  Remove carriage return before each test line in spec reporter. Served no purpose
  add "logo" field to package.json [ci skip]
  fix incorrect executable name with new version of commander
  add bower.json to published package for npmcdn support [ci skip]
  fix broken/wrong URLs in CHANGELOG.md [ci skip]
  Release v3.0.0-2
  rebuild mocha.js
  add browser-stdout to dependencies
  update CHANGELOG [ci skip]
  let child suites run if parent is exclusive; closes mochajs#2378 (mochajs#2387)
  Upgrade eslint package to 2.13 version (mochajs#2389)
  ...
sgilroy pushed a commit to TwineHealth/mocha that referenced this issue Feb 27, 2019
sgilroy pushed a commit to TwineHealth/mocha that referenced this issue Feb 27, 2019
…ribe-only

fix nested describe.only suites; closes mochajs#2406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants