Repository navigation
feat(cli): add junit reporter and output support - #590
Conversation
anurag629
left a comment
There was a problem hiding this comment.
Thanks @kachamsiddarth, nearly there. The XML has what #416 asked for (one <testsuite> per eval file, the failed reasons and the reply in <failure>, <, & and quotes escaped), and name=file with --output as the shortcut for one reporter reads well. All checks pass, including e2e.
Two things need to change before it can go in, both about writing the file:
-
A missing parent folder fails the run. CI setups usually write to something like
reports/evals.xml, and with noreports/folder thewriteFileatpackages/cli/src/test/command.ts:153throws after every test has run, so CI gets exit 2 and no report. Create the folder first, the way cassettes do atpackages/cli/src/test/cassette.ts:115:await mkdir(dirname(file), { recursive: true });
Then drop "Parent folders must exist" from the help (
packages/cli/src/main.ts:64) and the docs (testing.mdx:302), and have themissing/report.xmlcase intest-command.test.ts:388check that the file gets written there. -
A write error loses the recordings. The throw at
command.ts:155is inside the reporter loop and beforecassettes.saveat line 160, sochatcops test --record --output evals(a folder, so the write fails) calls every API and then saves none of what it recorded. A reporter after the failing one also never getsonEnd: with--reporter junit=evals --reporter prettythe terminal shows no results at all, sinceprettywrites everything inonEnd. Run everyonEndfirst, then save the cassettes, then write the files. For the test,tests/cassette.test.tshas the setup: run['test', '--record', '--output', 'evals'], expect exit 2, and checkcassetteOf(dir)was still written.
|
Implemented both requested review fixes:
Validation:
Pushed the follow-up commit to |
anurag629
left a comment
There was a problem hiding this comment.
Thanks @kachamsiddarth, both points are in. --output reports/evals.xml now creates reports/ before writing (packages/cli/src/test/command.ts:160), and the file writes come after every onEnd and cassettes.save, so --record --output evals keeps its recordings and --reporter junit=evals --reporter pretty still prints the summary. The two new tests check exactly those cases. CI passed on your last push, including e2e. dev moved since then, so I've updated the branch, and I'll merge once CI passes on that.
|
Merged, thanks @kachamsiddarth. |
What does this change?
Adds a JUnit XML reporter and
--outputsupport tochatcops test.The JUnit reporter generates CI-compatible XML with test cases, failures, execution errors, timing, and aggregate pass-rate information. Output destinations can be shared between reporters while validating duplicate, ambiguous, and invalid configurations.
Closes #416
How I tested this
pnpm --filter @chatcops/cli test— 142/142 passedpnpm --filter @chatcops/cli typecheck— passedpnpm --filter @chatcops/cli build— passedpnpm lint— passedpnpm test:coverage --maxWorkers=2— 2,463 passed, 65 skipped; coverage gates passedgit diff --check— passedpnpm install --frozen-lockfile— passed--outputusageAI assistance
Codex was used to assist with implementation, test generation, debugging, and validation. I reviewed the generated changes and ran the test, typecheck, build, lint, and coverage checks locally.
Checklist
devpnpm -r build,pnpm testandpnpm -r typecheckpass locallypnpm changeset) if this changescore,widgetorserverpnpm apirun andapi/committed if an exported type or option changed