-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
--forbid-only doesn't recognize it.only
when before
crashes
#3840
Comments
@medikoo It should be working (at least in $ bin/mocha test/integration/fixtures/options/forbid-only/only.fixture.js --forbid-only
forbid only - test marked with only
1) test2
0 passing (5ms)
1 failing
1) forbid only - test marked with only
test2:
Error: `.only` forbidden
at Runner.runTest (lib/runner.js:515:8)
at /Users/boneskull/projects/mochajs/mocha/lib/runner.js:647:12
at next (lib/runner.js:441:14)
at /Users/boneskull/projects/mochajs/mocha/lib/runner.js:451:7
at next (lib/runner.js:362:14)
at Immediate._onImmediate (lib/runner.js:419:5) The contents of that file: 'use strict';
describe('forbid only - test marked with only', function() {
it('test1', function() {});
it.only('test2', function() {});
it('test3', function() {});
}); |
before
crashes
@boneskull I looked closer into it, and narrowed it down. The issue is, that it becomes ignored if describe('something', () => {
before(function() {
this.skip();
});
it.only('only test', () => {});
});
describe('something else', () => {
it('other test', () => {
throw new Error('Fail');
});
});
To me it already looks as a design issue, fact that those errors are reported at test runtime, and not at test definition phase (when mocha gathers all Technically I would expect this error to be thrown before any test being run. |
before
crashesit.only
when before
crashes
I haven't independently confirmed this but seems plausible enough |
IIRC @outsideris changed it so |
I confirmed this bug. |
@boneskull , |
@outsideris, |
I have started looking into the bug 😄 😄 |
@rpgeeganage Good. :) |
Unsure there is a specified priority order in which tests are filtered out... |
…; closes #3840 * add fixtures that result in it.only combined with --forbid-only bug * adapt forbidonly test cases to cover it.only bug * check if forbid only option is set prior to marking a test only and throw error * change name of only test back to previous * use custom assertion for expecting error in forbidOnly tests * remove empty line * use createUnsupportedError instead of throw new Error * use createUnsupportedError instead of throw new Error * remove check if suite hasOnly and forbidOnly option is set as this is done before runtime * implement markOnly instance method in suite class * add unit test for suites markOnly method * throw exception if --forbid-only option is set even if suite is not selected by grep * adapt forbidOnly integration tests to check for failure if only suite is not selected by grep * fix jsdocs of suite markonly * Revert "fix jsdocs of suite markonly" This reverts commit cffc71a. * Revert "adapt forbidOnly integration tests to check for failure if only suite is not selected by grep" This reverts commit 336425a. * Revert "throw exception if --forbid-only option is set even if suite is not selected by grep" This reverts commit f871782. * Revert "add unit test for suites markOnly method" This reverts commit c2c8dc8. * Revert "implement markOnly instance method in suite class" This reverts commit 4b37e3c.
Not sure if it's a feature or a bug, but
--forbid-only
crashes only in case of approachingdescribe.only
but notit.only
.It caught me by a surprise.
Is it supposed to work that way? I assume it should crash same way it crashes for
describe.only
The text was updated successfully, but these errors were encountered: