Skip to content

test: remove manual Sinon restores - #3298

Merged
OrKoN merged 1 commit into
test/prefer-sinon-assertfrom
test/remove-manual-sinon-restore
Oct 22, 2026
Merged

OrKoN merged 1 commit into
test/prefer-sinon-assertfrom
test/remove-manual-sinon-restore

Conversation

@Lightning00Blade

Copy link
Copy Markdown
Collaborator

Stacked on #3297.

tests/setup.ts runs sinon.restore() after every test, so:

  • Removes the afterEach hooks in ClearcutSender.test.ts and DevToolsCommentBridge.test.ts that restored stubs and fake timers created on the default sandbox.
  • In ToolHandler.test.ts and input.test.ts, restores only the stub that has to be reset in the middle of the test instead of calling sinon.restore().
  • Renames TestServer.restore() to reset(), including the caller in scripts/eval_gemini.ts. It clears the registered routes, and a restore() call in afterEach reads like a Sinon restore.

This matches the DevTools no-manual-sinon-restore ESLint rule. When the rule is added, it needs to exempt tests/setup.ts, as DevTools does for its own test harness setup files.

User-visible changes

None. Tests and the eval script only.

Testing

  • npm run format
  • npm run test

tests/setup.ts runs `sinon.restore()` after every test, so:

- Remove the `afterEach` hooks in `ClearcutSender.test.ts` and
  `DevToolsCommentBridge.test.ts` that restored stubs and fake timers
  created on the default sandbox.
- In `ToolHandler.test.ts` and `input.test.ts`, restore only the stub
  that has to be reset in the middle of the test instead of calling
  `sinon.restore()`.
- Rename `TestServer.restore()` to `reset()`. It clears the registered
  routes, and a `restore()` call in `afterEach` reads like a Sinon
  restore.

This matches the DevTools `no-manual-sinon-restore` ESLint rule. The
rule would still need to exempt tests/setup.ts.
@OrKoN
OrKoN added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 0174df5 Oct 22, 2026
17 checks passed
@OrKoN
OrKoN deleted the test/remove-manual-sinon-restore branch October 22, 2026 05:14
MankhongGarden pushed a commit to MankhongGarden/chrome-devtools-mcp that referenced this pull request Oct 22, 2026
Stacked on ChromeDevTools#3298.

`assert.equal` from `node:assert` compares with `==`, so for example
`assert.equal(1, '1')` passes. Replaces its 153 uses in 13 test files
with `assert.strictEqual`. Three of the files import
`node:assert/strict`, where the two are the same; the rename keeps the
files consistent. No test relied on the loose comparison.

This matches the DevTools
[`no-assert-equal`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/scripts/eslint_rules/lib/no-assert-equal.ts)
ESLint rule. Its autofix is not used because it rewrites comparisons
against object and array literals to `assert.deepEqual`, which is also
loose in `node:assert`.

## User-visible changes

None. Tests only.

## Testing

- `npm run format`
- `npm run test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants