Skip to content

test: use sinon.assert for stub call checks - #3297

Merged
OrKoN merged 1 commit into
mainfrom
test/prefer-sinon-assert
Oct 22, 2026
Merged

OrKoN merged 1 commit into
mainfrom
test/prefer-sinon-assert

Conversation

@Lightning00Blade

Copy link
Copy Markdown
Collaborator

Replaces assert.ok(stub.notCalled), assert.ok(stub.calledOnce), assert.ok(stub.calledWith(...)) and assert.strictEqual(stub.callCount, n) with the matching sinon.assert methods, as AGENTS.md asks. A failing sinon.assert call names the stub and lists the calls it received.

The changes are the autofix of the DevTools prefer-sinon-assert ESLint rule.

This is part 1 of a stack that makes the code pass the DevTools custom ESLint rules that apply to this repository. The rules themselves are not added yet.

User-visible changes

None. Tests only.

Testing

  • npm run format
  • npm run test

Replace `assert.ok(stub.notCalled)`, `assert.ok(stub.calledOnce)`,
`assert.ok(stub.calledWith(...))` and
`assert.strictEqual(stub.callCount, n)` with the matching `sinon.assert`
methods, as AGENTS.md asks. A failing `sinon.assert` call names the stub
and lists the calls it received.

The changes are the autofix of the DevTools `prefer-sinon-assert` ESLint
rule.
@OrKoN
OrKoN added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 920c913 Oct 22, 2026
22 checks passed
@OrKoN
OrKoN deleted the test/prefer-sinon-assert 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#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`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/scripts/eslint_rules/lib/no-manual-sinon-restore.ts)
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`
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