Skip to content

Conversation

@cryptodev-2s
Copy link
Contributor

Explanation

Replace sinon with Jest timers and mocks

  • Remove sinon and @types/sinon from 21 packages
  • Replace sinon.useFakeTimers() with jest.useFakeTimers()
  • Replace sinon.stub() with jest.fn() or jest.spyOn()
  • Replace sinon.spy() with jest.fn()
  • Replace sinon.restore() with jest.restoreAllMocks()
  • Update advanceTime helper to use jest.advanceTimersByTime()
  • Convert sinon assertion patterns to Jest equivalents:
    • .callCount → toHaveBeenCalledTimes()
    • .called → toHaveBeenCalled()
    • .calledWith() → toHaveBeenCalledWith()
    • .firstCall.args → .mock.calls[0]
    • .getCall(n).args → .mock.calls[n]

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@cryptodev-2s cryptodev-2s force-pushed the refactor/replace-sinon-with-jest-timers branch 13 times, most recently from 0089112 to 9c74ff5 Compare February 2, 2026 09:54
Remove sinon from devDependencies in packages where it was declared
but not actually used:
- app-metadata-controller
- approval-controller
- core-backend
- selected-network-controller
Migrate all test files from sinon fake timers to Jest fake timers
and manual time control pattern for async test compatibility.
Migrate from sinon fake timers to Jest fake timers. For the onDegraded
test that measures actual elapsed time, use real timers with a lower
threshold to keep the test fast.
@cryptodev-2s cryptodev-2s force-pushed the refactor/replace-sinon-with-jest-timers branch from 9c74ff5 to b5c27a0 Compare February 2, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants