mocha
mocha copied to clipboard
Add file path to `xunit` reporter
Description of the Change
Expose test file path for each test case in the xunit
reporter.
<testsuite name="Mocha Tests" tests="2" failures="0" errors="0" skipped="0" timestamp="Tue, 17 May 2022 21:10:34 GMT" time="0.001">
<testcase classname="Array #indexOf()" name="should return -1 when the value is not present" file="/path/to/test/array.js" time="0"/>
<testcase classname="Set #has()" name="should return false when the value is not present" file="/path/to/test/set.js" time="0"/>
</testsuite>
Alternate Designs
Why should this be in core?
The test file path was already added to other reporters in this PR:
- https://github.com/mochajs/mocha/pull/4219
It seems the file path can be added to each reporter as needed.
Benefits
- Can be easier to find test file from file path instead of just test name, especially when overlapping/similar/identical test names are present, or in a large codebase
- In particular, it can be easier for automated tooling to find the test file from the file path as opposed to the test name when performing test analysis or other scripting
Possible Drawbacks
- Greater size / noise of output for people who don't need the file path
- Let me know if there's any other reason not to do this
Applicable issues
None.
This should be part of a minor release as an enhancement.
This PR hasn't had any recent activity, and I'm labeling it stale
. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!
I would love to have this for splitting tests on the CI!
@villelahdenvuo I just reopened the PR as #4985. Please comment or upvote the PR to express interest.