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

feat(runner): fix '.only()' exclusive feature, #1481 #1591

Closed
wants to merge 1 commit into from

Conversation

a8m
Copy link
Contributor

@a8m a8m commented Mar 10, 2015

This PR fix #1481, and also extends the .only() behaviour.
e.g:

  • it's not use grep anymore
  • support suite, test-case or both.
  • add the ability to run multiple .only() (on many files)

There's a tests for bdd, tdd and qunit interfaces that illustrate the point more clearly. so please take a look on it, and let me now what do you think.

@boneskull
Copy link
Member

@a8m Thanks! Hopefully someone will check this out soon--I'm going to be swamped for next few wks still. I'm thinking might be good for 3.0.0 release

@a8m
Copy link
Contributor Author

a8m commented Mar 11, 2015

Great @boneskull
/cc @travisjeffery @dasilvacontin

@erezesk
Copy link

erezesk commented Mar 11, 2015

@a8m looks great, tyvm!
+1

@dasilvacontin
Copy link
Contributor

Very busy lately, I'll try to dedicate some time to mocha this weekend. Anyways, thanks for the amazing work you've been pushing, @a8m! :)

@travisjeffery
Copy link
Contributor

looks pretty good, i've looked it over quickly a couple of times and got the feeling some parts could be simpler/clearer. i should get sometime tomorrow to look more in-depth

@a8m
Copy link
Contributor Author

a8m commented Mar 15, 2015

Great @travisjeffery
thx

@danielstjules
Copy link
Contributor

Looks pretty good! Works with almost all my tests, though I think I found a couple edge cases. The first is with the root suite I think:

describe.only('suite', function() {
  it.only('test', function() {});

  it('test2', function() {});
});

it('should not be ran', function() {});

it.only('another test', function() {});
danielstjules:~/git/mocha (pr1591)
$ ./bin/mocha --reporter spec example.js


  ✓ should not be ran
  ✓ another test
  suite
    ✓ test


  3 passing (10ms)

On master, however, I get the following:

danielstjules:~/git/mocha (master =)
$ ./bin/mocha --reporter spec example.js


  ✓ another test

  1 passing (6ms)

I think it was decided in the issue that spec-related only just take precedence over suite level, so with that in mind, should the correct output of this suite be:

  ✓ another test
  suite
    ✓ test


  2 passing (11ms)

@danielstjules
Copy link
Contributor

The second issue I hit was with the following test:

describe.only('suite', function() {
  it.only('test', function() {});

  it('test2', function() {});

  describe('suite2', function() {
    it('test3', function() {});
  });
});
danielstjules:~/git/mocha (pr1591)
$ ./bin/mocha --reporter spec example.js


  0 passing (3ms)

@a8m
Copy link
Contributor Author

a8m commented Mar 16, 2015

haha, I forgot to test the root suite, it should be fix here. I'll do it.
about the second example, I'll play with it and see what happens
thx @danielstjules

@a8m
Copy link
Contributor Author

a8m commented Mar 16, 2015

Fixed!
PTAL @danielstjules

@danielstjules
Copy link
Contributor

Those 2 look good, awesome!

Got another example, though I don't know if this is expected behavior or not. So this is probably not a bug, but just wanted to clarify :)

describe.only('suite', function() {
  describe('inner', function() {
    it.only('test', function() {});

    it('should not run', function() {});
  });

  it('should not run either', function() {});
});
dstjules:~/git/mocha (pr1591)
$ ./bin/mocha --reporter spec example.js


  suite
    ✓ should not run either
    inner
      ✓ test


  2 passing (8ms)

Is that expected output? If so, then the rest looks good to me!

@a8m
Copy link
Contributor Author

a8m commented Mar 16, 2015

This is the expected behaviour, PTAL bdd-test
Thanks for a agreat CR @danielstjules

@a8m
Copy link
Contributor Author

a8m commented Mar 16, 2015

rebased!

function filterOnly(suite) {
// If it has `only` tests
if(suite.hasOnly) suite.tests = suite.hasOnly;
// If it doesn't has a suites make it running
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments have a few typos.

@dasilvacontin
Copy link
Contributor

@a8m, in general, you are writing if(val) instead of if (val).

@a8m a8m force-pushed the master branch 2 times, most recently from f07b352 to 0e61241 Compare March 20, 2015 11:59
* Filter suites based on `isOnly` logic.
*
* @param {Array} suite
* @returns {*}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can set this now to Boolean?

@a8m a8m force-pushed the master branch 3 times, most recently from 50f86ea to d915328 Compare March 20, 2015 12:31
@dasilvacontin
Copy link
Contributor

LGTM 👍.

@travisjeffery, were you going to suggest any code improvements?

@a8m
Copy link
Contributor Author

a8m commented Mar 23, 2015

ping @mochajs/mocha

@dasilvacontin dasilvacontin added this to the v3.0.0 milestone Mar 23, 2015
@dasilvacontin
Copy link
Contributor

Well, goes.

@dasilvacontin
Copy link
Contributor

We'll have to wait for the v3.0.0 release tho.

@boneskull
Copy link
Member

@a8m I haven't gotten a chance to look at this yet, but please let me before this gets merged.

cc @mochajs/mocha

@boneskull boneskull self-assigned this Jul 10, 2015
var test = context.it(title, fn);
var reString = '^' + escapeRe(test.fullTitle()) + '$';
mocha.grep(new RegExp(reString));
var test = context.it(title, fn)
Copy link
Member

Choose a reason for hiding this comment

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

various places in this PR will need to be linted

@a8m
Copy link
Contributor Author

a8m commented Jul 18, 2015

Replaced with #1807(rebased on top of v3.0.0)

@a8m a8m closed this Jul 18, 2015
@Vanuan
Copy link

Vanuan commented Feb 10, 2016

WTF? Are you trying to fix all bugs with one PR? Release some fix already.

@boneskull
Copy link
Member

@Vanuan I understand you are probably frustrated with the .only() bug(s), but please try to be constructive. Thanks!

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

Successfully merging this pull request may close these issues.

describe.only matches more that one describe test suite
8 participants