-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Feature Request Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faq
label, but none matched my issue. - I want to provide a PR to resolve this
Overview
Today, the xunit
reporter always fills the file
attribute with the fully qualified path to the file.
> npx mocha --reporter=xunit
<testsuite name="Mocha Tests" tests="1" failures="0" errors="0" skipped="0" timestamp="Thu, 30 Jan 2025 00:11:09 GMT" time="0.001">
<testcase classname="add" name="should add two numbers" file="/private/tmp/test-mocha/test/add.test.js" time="0"/>
</testsuite>
In CircleCI, when a test fails, they provide a dedicated UI that reads junit-compatible xml
files and shows failures in a user-friendly way:
However, because the fully qualified path is provided, I have to delete the prefix (/home/circleci/project
) to paste it into my editor to pull up the file.
With my jest test suites and the junit reporter, I can easily just click the "copy" icon because it's the relative path:
Suggested Solution
We should introduce a new reporterOption
for this feature. Perhaps it's called useRelativeFilePath
and defaults to false
to retain backward compatibility.
We could alternatively use a mode like filePathMode: 'relative' | 'absolute'
, defaulting to absolute
.
Alternatives
For now, I'm just using sed
to edit the file after it's produced. But it would be nice to remove this additional step.
Additional Info
No response