Repository navigation
🌱 test(diagnostics): pin period, uptime and clearInterval to a mocked clock - #424
Merged
Merged
Conversation
…ed clock The nightly Stryker report (run 41171362594 on f2b3df9) shows the interval maths and the stop() clearInterval in startDiagnostics surviving mutation: seconds/1000, uptime*1000, Date.now()+startedAt and a dropped clearInterval all pass the suite, because the existing tests only check that some periodic line arrives and that uptime_s is a number. Drive the interval and Date through node:test mock timers from a non-zero epoch and assert the exact tick boundary, the exact uptime_s values and that nothing fires after stop(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
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.
Why
The advisory nightly Stryker report (run 41171362594 on f2b3df9) lists 7 surviving mutants in
src/diagnostics.ts. Four of them are real assertion gaps, not equivalent mutants:seconds / 1000— a user-supplied--diagnostics 2could schedule the report every ~1 ms and the suite would not notice.(Date.now() - startedAt) * 1000andDate.now() + startedAt—uptime_scould be wildly wrong; the suite only checkedtypeof uptime_s === 'number'.clearInterval(timer)—stop()could leave the interval running and the suite would still pass, because every existing test resets the mock timers before callingstop().The remaining three (L31
flag === 'true' ? NaNvsNumber('true'), andtimer.unref()) are equivalent or unobservable from a unit test and are left alone.What
One new test in
src/diagnostics.test.tsthat drivessetIntervalandDatethroughnode:testmock timers from a non-zero epoch and asserts the exact 2000 ms tick boundary, the exactuptime_svalues (2, 4, 4), and that nothing fires afterstop(). Verified each of the four mutants above now fails the suite when applied by hand todist/diagnostics.js.npm run lint,npm run test:coverage(438 pass; 99.76 / 97.12 / 100) green locally.Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88