Repository navigation
test: use sinon.assert for stub call checks - #3297
Merged
Merged
Conversation
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
approved these changes
Oct 22, 2026
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`
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.
Replaces
assert.ok(stub.notCalled),assert.ok(stub.calledOnce),assert.ok(stub.calledWith(...))andassert.strictEqual(stub.callCount, n)with the matchingsinon.assertmethods, as AGENTS.md asks. A failingsinon.assertcall names the stub and lists the calls it received.The changes are the autofix of the DevTools
prefer-sinon-assertESLint 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 formatnpm run test