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

An option to disable the "root suite". #53

Closed
ThatBrianDude opened this issue Sep 28, 2017 · 5 comments
Closed

An option to disable the "root suite". #53

ThatBrianDude opened this issue Sep 28, 2017 · 5 comments

Comments

@ThatBrianDude
Copy link

Im not exactly sure what the root suite is useful for and would be very happy if I could disable it so that its not included in the output xml. I am using this tool to view my mocha tests in the xunit-viewer but have no need for any root suite thats always a success.

What exactly is it meant for?

@clayreimann
Copy link
Collaborator

Not sure, that's the way it's always been.

Without digging into the docs, perhaps junit requires a single top-level suite?

PRs always welcome. You'd want to look at this code

@ThatBrianDude
Copy link
Author

I have disabled it but not sure its worthy of a PR as its kind of hacky what I did. The reason being when I first change this:

testsuites: [ rootSuite ].concat(testsuites)

to this:

testsuites: testsuites

it didnt change anything. Which I thought was very weird. Only after changing that line to this:

testsuites: testsuites.splice(1,testsuites.length)

did I get the expected result, without a root suite. I thought the original line of code implied that the root suite was being added right there but that doesnt seem to be whats happening.

My modification is working but I havent found time to dig into exactly why that was so I probably wont be creating a PR.

@egorvas
Copy link

egorvas commented Aug 21, 2018

@jasonk
Copy link

jasonk commented Nov 5, 2018

It's Mocha that adds the root suite. It's intended primarily for things like global before/after hooks, but if you add any tests outside of a describe they will end up attached to the root suite also. I wouldn't suggest creating a PR to hide it because while it may always be a success in your particular test suite, that won't always be the case for everyone.

https://mochajs.org/#root-level-hooks

ROOT-LEVEL HOOKS
You may also pick any file and add “root”-level hooks. For example, add beforeEach() outside of all describe() blocks. This will cause the callback to beforeEach() to run before any test case, regardless of the file it lives in (this is because Mocha has an implied describe() block, called the “root suite”).

@clayreimann
Copy link
Collaborator

Thanks for the input @jasonk. Knowing that mocha has an implicit top-level describe I feel the presence of the root suite is, in fact, required.

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

No branches or pull requests

4 participants