Skip to content

Chrome DevTools for coding agents

test: fix missing sinon.restore (#989)

Alex Rudenkoc9691c6250e6
diff --git a/tests/DevtoolsUtils.test.ts b/tests/DevtoolsUtils.test.ts
index a6f5d113..a5e43009 100644
--- a/tests/DevtoolsUtils.test.ts
+++ b/tests/DevtoolsUtils.test.ts
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert';
-import {describe, it} from 'node:test';
+import {afterEach, describe, it} from 'node:test';
import sinon from 'sinon';
@@ -95,6 +95,10 @@ describe('urlsEqual', () => {
});
describe('UniverseManager', () => {
+ afterEach(() => {
+ sinon.restore();
+ });
+
it('calls the factory for existing pages', async () => {
const browser = getMockBrowser();
const factory = sinon.stub().resolves({});
diff --git a/tests/McpContext.test.ts b/tests/McpContext.test.ts
index e3683152..3783f55f 100644
--- a/tests/McpContext.test.ts
+++ b/tests/McpContext.test.ts
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert';
-import {describe, it} from 'node:test';
+import {afterEach, describe, it} from 'node:test';
import sinon from 'sinon';
@@ -16,6 +16,10 @@ import type {TraceResult} from '../src/trace-processing/parse.js';
import {getMockRequest, html, withMcpContext} from './utils.js';
describe('McpContext', () => {
+ afterEach(() => {
+ sinon.restore();
+ });
+
it('list pages', async () => {
await withMcpContext(async (_response, context) => {
const page = context.getSelectedPage();
diff --git a/tests/PageCollector.test.ts b/tests/PageCollector.test.ts
index 48e60cf3..6a8155fc 100644
--- a/tests/PageCollector.test.ts
+++ b/tests/PageCollector.test.ts
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert';
-import {beforeEach, describe, it} from 'node:test';
+import {afterEach, beforeEach, describe, it} from 'node:test';
import type {Frame, HTTPRequest, Target, Protocol} from 'puppeteer-core';
import sinon from 'sinon';
@@ -302,6 +302,10 @@ describe('ConsoleCollector', () => {
};
});
+ afterEach(() => {
+ sinon.restore();
+ });
+
it('emits issues on page', async () => {
const browser = getMockBrowser();
const page = (await browser.pages())[0];
diff --git a/tests/formatters/IssueFormatter.test.ts b/tests/formatters/IssueFormatter.test.ts
index c46fbb6f..de176485 100644
--- a/tests/formatters/IssueFormatter.test.ts
+++ b/tests/formatters/IssueFormatter.test.ts
@@ -21,7 +21,7 @@ describe('IssueFormatter', () => {
});
afterEach(() => {
- getIssueDescriptionStub.restore();
+ sinon.restore();
});
it('formats an issue message', t => {
diff --git a/tests/tools/extensions.test.ts b/tests/tools/extensions.test.ts
index 65f645ab..c8bbce68 100644
--- a/tests/tools/extensions.test.ts
+++ b/tests/tools/extensions.test.ts
@@ -6,7 +6,7 @@
import assert from 'node:assert';
import path from 'node:path';
-import {describe, it} from 'node:test';
+import {afterEach, describe, it} from 'node:test';
import sinon from 'sinon';
@@ -34,6 +34,10 @@ function extractId(response: McpResponse) {
}
describe('extension', () => {
+ afterEach(() => {
+ sinon.restore();
+ });
+
it('installs and uninstalls an extension and verifies it in chrome://extensions', async () => {
await withMcpContext(async (response, context) => {
// Install the extension
diff --git a/tests/tools/pages.test.ts b/tests/tools/pages.test.ts
index 2d4110f8..cf75af22 100644
--- a/tests/tools/pages.test.ts
+++ b/tests/tools/pages.test.ts
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert';
-import {describe, it} from 'node:test';
+import {afterEach, describe, it} from 'node:test';
import type {Dialog} from 'puppeteer-core';
import sinon from 'sinon';
@@ -23,6 +23,10 @@ import {
import {html, withMcpContext} from '../utils.js';
describe('pages', () => {
+ afterEach(() => {
+ sinon.restore();
+ });
+
describe('list_pages', () => {
it('list pages', async () => {
await withMcpContext(async (response, context) => {