ember-cli-mocha icon indicating copy to clipboard operation
ember-cli-mocha copied to clipboard

Mocha@3: it.only does not work

Open webpapaya opened this issue 10 years ago • 12 comments

Hey I'm trying to only run a single test with it.only like it's defined in here https://mochajs.org/#exclusive-tests, but both tests are running when i open up my test suite in the browser. Am I doing something wrong or is this feature not supported by ember-cli-mocha?

My test looks like:

describe('test it.only feature', function() {
  it('should not run', function() {
    expect(true).to.equal(true);
  });

  it.only('should run', function() {
    expect(true).to.equal(true);
  });
});

Update: A workarround to this issue is to use the grep argument and paste in the test name. Like

http://localhost:7357/7159/tests/index.html?hidepassed&grep=should%20run

Thanks, Thomas

webpapaya avatar Aug 11 '15 10:08 webpapaya

I've never had issues with this. Out of curiosity, have you tried it without the only on your describe line?

clekstro avatar Aug 11 '15 12:08 clekstro

Hey yeah I tried describe.only as well, with the same effect. For now the solution with grep is totally fine for me.

webpapaya avatar Aug 12 '15 13:08 webpapaya

We will need a demo repo to track this down...

rwjblue avatar Aug 12 '15 13:08 rwjblue

This has always worked for me. Here's an example

blimmer avatar Aug 30 '15 00:08 blimmer

I have, however, noticed that you can't use .only along with grep= query param.

blimmer avatar Jun 13 '16 15:06 blimmer

I'm also seeing this now, I just don't know yet at what point it surfaced.

Update: my issue surfaced because mocha implicitly upgraded to 3.0.0. This isn't an issue with ember-cli-mocha. Backing it back down to 2.x resolved the issue.

jasonmit avatar Aug 03 '16 22:08 jasonmit

@jasonmit do you have any clue why this popped up with Mocha 3?

Turbo87 avatar Aug 14 '16 11:08 Turbo87

this is most likely related to https://github.com/teddyzeenny/ember-mocha-adapter/blob/master/adapter.js#L169-L172 and Mocha 3 having done some changes in the .only() handling

Turbo87 avatar Aug 14 '16 12:08 Turbo87

Any news on this? Is this still blocking #167?

phyrog avatar May 19 '17 08:05 phyrog

@phyrog yes, haven't found a good solution to this issue yet 😞

Turbo87 avatar May 19 '17 10:05 Turbo87

IMHO, we should drop the auto-run wrapping that we do inside it and begin requiring a return wait() at the end for the tests to properly wait. I believe this should unblock the Mocha 3 work.

@Turbo87 - Is that correct?

rwjblue avatar Jul 20 '17 22:07 rwjblue

@rwjblue in theory yes, but it would obviously be annoying for Mocha users that don't use async/await yet. I wanted to go back and see if there is really no way to us to hook in anywhere but I haven't found the time yet 😞

Turbo87 avatar Jul 25 '17 17:07 Turbo87