You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
junitReporter: per-<testsuite> timestamp uses report-write time, not suite-start time #5668
In the JUnit XML produced by junitReporter, the root <testsuites timestamp="..."> is correct (the actual run-start time), but the nested <testsuite timestamp="..."> for each suite is wrong — it holds the moment the XML file was written (i.e. after that suite, including AfterSuite, finished), not when the suite started.
Root cause
lib/plugin/junitReporter.js:
setAttr(root,'timestamp',toIso(result.stats&&result.stats.start))// correct: Mocha's real run-start stat...setAttr(suiteEl,'timestamp',toIso(suite&&suite.startedAt))// suite.startedAt is never set anywhere
suite.startedAt doesn't exist on Mocha's Suite — I grepped the whole codeceptjs package and startedAt is only ever set on individual test objects (lib/listener/steps.js:20), never on a Suite. So suite && suite.startedAt is always undefined, toIso() falls through to its new Date() fallback, and the <testsuite> gets stamped with "now" at write time — effectively the run's end time, not its start.
To Reproduce
Run any suite with -p junitReporter (or the junitReporter plugin enabled in config).
Open the generated report.xml.
Compare the root <testsuites timestamp> against the nested <testsuite timestamp> — the nested one matches the file's mtime / run-finish time instead of run-start time.
Example from a real run (root suite ran 08:09:58–08:10:20 local / 06:09:58–06:10:20 UTC):
The root timestamp (06:09:58.974Z) is right. The suite timestamp (06:10:20.079Z) matches report.xml's file mtime (08:10:20.079420438 +0200 local), i.e. write time, not start time — a ~22s discrepancy in this run.
Expected behavior
The <testsuite>timestamp attribute should reflect when that suite actually started (e.g. captured via event.suite.before, or derived from the earliest test.startedAt/test.opts.startedAt among the suite's tests), not the report-write time.
Environment
CodeceptJS: 4.0.9
Node: 24.18.0
OS: Linux 6.17, Ubuntu 24.04.4 LTS
Related
Same underlying failure pattern — "now" captured at report-build/write time gets mislabeled as a start timestamp — also found and reported separately in @testomatio/reporter's HTML report ("Started At" field): testomatio/reporter#903
🤖 Filed with the help of Claude Sonnet 5 (Anthropic)
Here is the part of the XML where I noticed the issue:
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesname="CodeceptJS"tests="5"failures="0"skipped="0"errors="0"time="18.999"timestamp="2026-07-30T06:09:58.974Z"><testsuitename="LeaveRequest"id="0"tests="5"failures="0"skipped="0"errors="0"time="18.999"timestamp="2026-07-30T06:10:20.079Z"hostname="rog"file="/home/mirao/workspace/codeceptjs/tests/s4p/LeaveRequest_test.ts"><testcasename="Verify creating a leave request via the Home 'New leave request' button"classname="LeaveRequest"time="7.863"file="/home/mirao/workspace/codeceptjs/tests/s4p/LeaveRequest_test.ts"><properties><propertyname="browser"value="webkit"/><propertyname="browserVersion"value="26.5"/><propertyname="windowSize"value="1920x1080"/></properties><system-out>I fill field #DEV_LOGIN_EMAIL_INPUT, "at962937553631618@autotest.lab" (913ms)
...
test log (in GMT+2)
mirao@rog:~/workspace/codeceptjs/tests/s4p$ codeceptjs run LeaveRequest_test.ts --profile personal,webkit --verbose --colors|ts
Jul 30 08:09:58 [TESTOMATIO] Testomatio Reporter v2.12.0
Jul 30 08:09:58 ***************************************
Jul 30 08:09:58 nodeInfo: 24.18.0
Jul 30 08:09:58 osInfo: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
Jul 30 08:09:58 cpuInfo: (16) x64 AMD Ryzen 7 9700X 8-Core Processor
Jul 30 08:09:58 chromeInfo: 151.0.7922.71
Jul 30 08:09:58 edgeInfo: "N/A"
Jul 30 08:09:58 firefoxInfo: 152.0.6
Jul 30 08:09:58 safariInfo: N/A
Jul 30 08:09:58 playwrightBrowsers: "chromium: 149.0.7827.55, firefox: 151.0, webkit: 26.5"
Jul 30 08:09:58 If you need more detailed info, just run this: npx codeceptjs info
Jul 30 08:09:58 ***************************************
Jul 30 08:09:58 CodeceptJS v4.0.9 #StandWithUkraine
Jul 30 08:09:58 Using test root "/home/mirao/workspace/codeceptjs/tests/s4p"
Jul 30 08:09:58 [TESTOMATIO] Pipes: HTML Reporter
Jul 30 08:09:58 Helpers: Common, Playwright, REST, JSONResponse, FileSystem, ChaiWrapper, CmdHelper, PixelmatchHelper, S4P, MySQL_DB, S4P_server
Jul 30 08:09:58 Plugins: screenshot, retryFailedStep, testomatio, junitReporter, customLocator
Jul 30 08:09:58
Jul 30 08:09:58 LeaveRequest --
...
Jul 30 08:10:19 I see text equals "Aug 2, 2026", #REQUESTS_LIST_ITEM_DATE_RANGE
Jul 30 08:10:19 › [Element] <div dir="auto" class="css-text-146c3p1 select-text font-sans text-sm text-muted-foreground" data-te...
Jul 30 08:10:19 ✔ OK in 1674ms
Jul 30 08:10:19
Jul 30 08:10:19 AfterSuite()
Jul 30 08:10:19 I delete child 463
Jul 30 08:10:19 I delete child 464
Jul 30 08:10:19 I delete parent 759
Jul 30 08:10:20
Jul 30 08:10:20
Jul 30 08:10:20 OK | 5 passed // 21s
Jul 30 08:10:20 › <junitReporter> JUnit report saved to /home/mirao/workspace/codeceptjs/tests/s4p/output/report.xml
Jul 30 08:10:20 ⏳ The test results will be added to the HTML report. It will take some time...
Jul 30 08:10:20 📊 The HTML report was successfully generated. Full filepath: file:///home/mirao/workspace/codeceptjs/tests/s4p/output/report/testomatio-report.html
Activity
mirao commentedon Jul 30, 2026
Here is the part of the XML where I noticed the issue:
test log (in GMT+2)
fix(junitReporter): stamp suites with their real start time (codecept…