feat(plugin): JUnit XML reporter plugin with steps & meta#5558
Merged
Conversation
New built-in `junitReporter` plugin that writes a standard JUnit
`<testsuites>/<testsuite>/<testcase>` XML report after a run, consumable
by Jenkins, GitLab CI, CircleCI, GitHub Actions test reporters, etc.
Beyond plain pass/fail/skip + durations + error stack, each `<testcase>`
includes CodeceptJS-specific data Mocha's reporter can't provide:
- `<properties>` — the test's meta information: every `meta` key from
`Scenario('...', { meta })`, plus its `tags` and `retries`
- `<system-out>` — an indented step/substep log; substeps nested under
their meta step, only failed steps marked
- `<failure>` — message, type, stack, and (optionally) the step trace
Reads the already-collected `test.steps` on `event.all.result`
(and `event.workers.result`); builds XML via `@xmldom/xmldom`.
Config: `outputName`, `output`, `testGroupName`, `attachMeta`,
`attachSteps`, `stepsInFailure`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
db42492 to
4a0bac5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a built-in
junitReporterplugin that writes a standard JUnit-compatible XML report (<testsuites>/<testsuite>/<testcase>) after a test run — consumable by Jenkins, GitLab CI, CircleCI, GitHub Actions test reporters, etc.Unlike feeding Mocha's
mocha-junit-reporter, this plugin understands CodeceptJS, so each<testcase>carries:<properties>— the test's meta information: everymetakey fromScenario('...', { meta }), plus itstagsandretries<system-out>— an indented step/substep log; substeps are nested under their meta step, and only failed steps are marked ([FAILED])<failure>— for failed tests: error message, type, stack trace and (optionally) the step trace with the failing step marked<skipped/>for skipped/pending testsIt reads the already-collected
test.stepsonevent.all.result(andevent.workers.result, write-once) — no extra per-step listeners — and builds XML with@xmldom/xmldom(already a dependency).Usage
Sample output
Notes / limitations
run-workers, steps are serialized between processes so substep nesting flattens to one level (same constraint asaiTraceetc.); pass/fail/skip/timings/meta still recorded.Files
lib/plugin/junitReporter.js— the plugin (+ JSDoc, which feedsdocs/plugins.md)test/unit/junitReporter_test.js— unit tests (well-formedness,<properties>= meta,<system-out>step tree, failures, skipped, custom filename, write-once)docs/plugins.md—## junitReportersectionTest plan
npx mocha test/unit/junitReporter_test.js— 8 passingeslintcleannode bin/codecept.js run --config test/data/sandbox/codecept.js -p junitReporterwrites a validoutput/report.xmlwith multiple suites, tags and step logs🤖 Generated with Claude Code