-
-
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
describe.only matches more that one describe test suite #1481
Comments
Are the two suites in the same file or in different files? |
different files |
If you had tons of test files, making What about using |
my workflow is actually to have all tests in a runnable state and then only add the .only for the method or test suite I want to code (which makes it very efficient) And it is easy to spot if there is an .only left behind because not all tests will run |
What we could do is: |
While you are doing that, another behaviour that happens which is breaks the test workflow is the fact that the .only on the describe overrides the .only on the it Ideally the It should 'win over', in fact maybe even capture 'all its' that are flagged and only run these. This will be the equivalent of 'just run theses tests'. My workflow is usually:
Does that make sense? |
Yeah, the inner What happens if you don't add Wouldn't it be easier to add |
well the whole test suite starts to runs which is not a massive issue since it is quick (about 15secs (including on UI driven tests, like the ones you can see here), and I can also stop it. But it would be nicer to not have that triggered. The reason I don't like the Regarding your comment on:
I'm not sure if I am fully aware of all those options and capabilities. Can you point me to a doc/article/blog about it? Thanks |
Okay, sorry about the tags thing, the PR hasn't been finished yet. Can't you make the tests run only when you save the file? We'll discuss |
If The forthcoming tagging API will help you "tag" specs and suites so you can more efficiently run a subset of tests. |
FWIW I don't really like the |
That's what makes sense. I think more than a few people must have thought 'wth' when they realised current behaviour. |
I'm going to tag this as Bug. I can't think of an efficient, elegant solution off of the top of my head, so I'd be willing to look at PRs for this. |
He could even run a different command depending on a ENV variable. |
And many of the issues I see raised here are non-issues for those of us that choose to use a task runner (Grunt, Gulp, |
I heard TJ wanted to kill |
@dasilvacontin I'm behind that. |
@boneskull 💣 💥 |
Hi @boneskull the issue is more for the ones that what to have semi-real time feedback on the tests executed. I already have a set-up where I can run all tests on background (ala Grunt, Gulp, make) , but what I really want to to have a REPL style interactive TDD environment, where I am continuously modifying the test(s) to execute (based on the tests I'm writing or code I'm modifying). Actually on this topic, another option would be to try to detect (like ncrunch does) which tests are affected by code changes (and only run those) |
@dasilvacontin Line 99 in 53c4144
This is the same method that Line 79 in 81d6b94
The issue that @DinisCruz is having is both test suite names use https://gist.github.com/twolfson/9b769b716dd7bad383ac When it is run normally, it runs only the suite from > mocha test-one.js test-two.js
one with a .only
✓ is run separately from other tests
1 passing (4ms) When we use change the title in // Updated `test-one.js`
describe.only('.only', function () {
it('is run separately from other tests', function () { > mocha test-one.js test-two.js
.only
✓ is run separately from other tests
two without a .only
1) is not run
1 passing (5ms)
1 failing
1) two without a .only is not run:
AssertionError: 1 === 2 @DinisCruz As a workaround until describe 'A Boolean constructor',->
describe 'An assertion against the Boolean constructor',-> |
Sorry, my bad. We need a PR for this then. Not even with regex support for grep we could make it work for all cases. |
@boneskull Would it be possible to create a Maybe we can do something like |
Current behaviour is really really unexpected. describe.only = ((only) ->
(args...) ->
if typeof args[0] is 'string' then args[0] += '\u200b' #zero-width whitespace
only.apply @, args
)(describe.only) |
Try that. |
@tylerhjones That solution will fit most cases but not if there are 2 cases with the same // We should only run this block
describe.only('A server', function () {
describe('receiving an HTTP request', function () {
it('replies successfully', function () {
});
});
});
describe('A server', function () { /* Similar setup but different test */ }); We need to solve it from file and position within the file. That is a valid unique identifer for each block. |
|
This PR fix mochajs#1481, and also extends the .only() behaviour. (i.e: it's not use grep anymore, support suite, test-case or both, add the ability to run multiple .only)
This PR fix mochajs#1481, and also extends the .only() behaviour. (i.e: it's not use grep anymore, support suite, test-case or both, add the ability to run multiple .only)
@Vanuan lol.. I totally agree.. this has been marked as a bug since Dec 2014. This bit me in the butt today as well. The |
wow, I thought I might help by putting in a fix, but the latest pull request changes 17 files and hundreds of lines of code...how complicated is this |
It's not complicated. It's that maintainers are trying to fix more and more issues in one pull request. |
Those are mostly integration tests. The lib change itself is 6 files and 83 loc with comments. |
First pull request, #1492 covered all use cases except duplicate test names. For me, duplicate test names is a bug, not a feature. Mocha should've stack-traced if smb registered duplicate tests. |
This PR fix #1481, and also extends the .only() behaviour. (i.e: it's not use grep anymore, support suite, test-case or both, add the ability to run multiple .only)
PR for this is merged into v3.0.0 branch via 8a75434 |
This PR fix #1481, and also extends the .only() behaviour. (i.e: it's not use grep anymore, support suite, test-case or both, add the ability to run multiple .only)
Is it possible to use the old behavior (i.e., |
|
If I have these two test suites (just showing the first one)
and
If I add .only to the first one :
both will now be executed:
and I would expect only the first one to execute
I assuming that mocha behind the scenes is not keeping a pointer to the actual tests to execute, it is just keeping the name/string, which is then searched on all tests/describes loaded (is that correct?)
The text was updated successfully, but these errors were encountered: