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

When using --delay, .only() no longer works #1838

Closed
wlingke opened this issue Aug 19, 2015 · 9 comments
Closed

When using --delay, .only() no longer works #1838

wlingke opened this issue Aug 19, 2015 · 9 comments
Labels
status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer

Comments

@wlingke
Copy link

wlingke commented Aug 19, 2015

When I run a test with --delay, and I specify only(), the entire test suite gets run, not just the only block.

@boneskull
Copy link
Member

@wlingke can you please provide some example code

@boneskull boneskull added Unconfirmed status: waiting for author waiting on response from OP - more information needed labels Aug 19, 2015
@wlingke
Copy link
Author

wlingke commented Aug 20, 2015

run below with --delay will fail yield in test two being run.

var assert = require('assert')
setTimeout(function(){

    describe.only('Should only run this', function(){
        it('passing test', function(){
            assert(true)
        })
    });

    describe('Should not run this', function(){
        it('failing test', function(){
            assert(false)
        })
    });

    run()
}, 1000);

@trueter
Copy link

trueter commented Dec 2, 2015

Can confirm.

@stale
Copy link

stale bot commented Oct 17, 2017

I am a bot that watches issues for inactivity.
This issue hasn't had any recent activity, and I'm labeling it stale. In 14 days, if there are no further comments or activity, I will close this issue.
Thanks for contributing to Mocha!

@stale stale bot added the stale this has been inactive for a while... label Oct 17, 2017
@JustinLivi
Copy link

Can confirm to keep this from closing.

@stale stale bot removed the stale this has been inactive for a while... label Oct 17, 2017
@ScottFreeCode ScottFreeCode added type: bug a defect, confirmed by a maintainer status: accepting prs Mocha can use your help with this one! and removed status: waiting for author waiting on response from OP - more information needed unconfirmed-bug labels Oct 18, 2017
@ScottFreeCode
Copy link
Contributor

Yup, tried it out and this is still an issue.

Surprising, because only got redesigned and rewritten in version 3.

@ScottFreeCode
Copy link
Contributor

Fix: move

mocha/lib/runner.js

Lines 813 to 816 in 16ffca2

// If there is an `only` filter
if (hasOnly(rootSuite)) {
filterOnly(rootSuite);
}
to between
function start () {
and
self.started = true;

How to write tests for it though... probably will have to use the test/integration model with test/integration/fixtures...

@silviom
Copy link
Contributor

silviom commented Jan 19, 2018

Hi, @ScottFreeCode. I have created the following PR for the fix. Thanks for the instructions.
#3215

@juergba
Copy link
Member

juergba commented Jan 22, 2019

This issue can be closed, see PR #3215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

7 participants