Skip to content

Chrome DevTools for coding agents

test: drop node20 code in tests (#2146)

Alex Rudenkof8fb2a9236d1
diff --git a/scripts/test.mjs b/scripts/test.mjs
index d545f392..0d427847 100644
--- a/scripts/test.mjs
+++ b/scripts/test.mjs
@@ -38,11 +38,7 @@ if (userArgs.length > 0) {
files.push(testPath);
}
} else {
- const isNode20 = process.version.startsWith('v20.');
if (flags.includes('--test-only')) {
- if (isNode20) {
- throw new Error(`--test-only is not supported for Node 20`);
- }
const {glob} = await import('node:fs/promises');
for await (const tsFile of glob('tests/**/*.test.ts')) {
const content = await readFile(tsFile, 'utf8');
@@ -55,11 +51,7 @@ if (userArgs.length > 0) {
process.exit(0);
}
} else if (files.length === 0) {
- if (isNode20) {
- files.push('build/tests');
- } else {
- files.push('build/tests/**/*.test.js');
- }
+ files.push('build/tests/**/*.test.js');
}
}
diff --git a/tests/McpContext.test.ts b/tests/McpContext.test.ts
index 1d5d2cdc..52e2293f 100644
--- a/tests/McpContext.test.ts
+++ b/tests/McpContext.test.ts
@@ -148,7 +148,7 @@ describe('McpContext', () => {
response.setIncludeNetworkRequests(true);
const result = await response.handle('test', context);
- t.assert.snapshot?.(JSON.stringify(result.structuredContent, null, 2));
+ t.assert.snapshot(JSON.stringify(result.structuredContent, null, 2));
});
});
@@ -165,7 +165,7 @@ describe('McpContext', () => {
response.attachNetworkRequest(456);
const result = await response.handle('test', context);
- t.assert.snapshot?.(JSON.stringify(result.structuredContent, null, 2));
+ t.assert.snapshot(JSON.stringify(result.structuredContent, null, 2));
});
});
@@ -212,7 +212,7 @@ describe('McpContext', () => {
});
const result = await response.handle('test', context);
- t.assert.snapshot?.(JSON.stringify(result.structuredContent, null, 2));
+ t.assert.snapshot(JSON.stringify(result.structuredContent, null, 2));
fromStub.restore();
});
diff --git a/tests/McpResponse.test.ts b/tests/McpResponse.test.ts
index 20de819a..d63bf7ba 100644
--- a/tests/McpResponse.test.ts
+++ b/tests/McpResponse.test.ts
@@ -56,8 +56,8 @@ describe('McpResponse', () => {
context,
);
assert.equal(content[0].type, 'text');
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -72,8 +72,8 @@ describe('McpResponse', () => {
context,
);
assert.equal(content[0].type, 'text');
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -87,8 +87,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -110,8 +110,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -134,8 +134,8 @@ describe('McpResponse', () => {
context,
);
assert.equal(content[0].type, 'text');
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -153,8 +153,8 @@ describe('McpResponse', () => {
context,
);
assert.equal(content[0].type, 'text');
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(JSON.stringify(structuredContent, null, 2));
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(JSON.stringify(structuredContent, null, 2));
});
});
@@ -173,10 +173,8 @@ describe('McpResponse', () => {
context,
);
assert.equal(content[0].type, 'text');
- t.assert.snapshot?.(
- stabilizeResponseOutput(getTextContent(content[0])),
- );
- t.assert.snapshot?.(
+ t.assert.snapshot(stabilizeResponseOutput(getTextContent(content[0])));
+ t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(structuredContent),
null,
@@ -185,7 +183,7 @@ describe('McpResponse', () => {
);
});
const content = await readFile(filePath, 'utf-8');
- t.assert.snapshot?.(stabilizeResponseOutput(content));
+ t.assert.snapshot(stabilizeResponseOutput(content));
} finally {
await rm(filePath, {force: true});
}
@@ -304,8 +302,8 @@ describe('McpResponse', () => {
context,
);
assert.equal(content[0].type, 'text');
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -318,8 +316,8 @@ describe('McpResponse', () => {
context,
);
await context.emulate({});
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -331,11 +329,11 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
+ t.assert.snapshot(getTextContent(content[0]));
assert.equal(content[1].type, 'image');
assert.strictEqual(getImageContent(content[1]).data, 'imageBase64');
assert.strictEqual(getImageContent(content[1]).mimeType, 'image/png');
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -348,8 +346,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -362,8 +360,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -378,8 +376,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -392,8 +390,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -406,8 +404,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -430,8 +428,8 @@ describe('McpResponse', () => {
context,
);
await page.getDialog()?.dismiss();
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -454,8 +452,8 @@ describe('McpResponse', () => {
context,
);
await page.getDialog()?.dismiss();
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -471,8 +469,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -488,8 +486,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -526,8 +524,8 @@ describe('McpResponse', () => {
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -548,8 +546,8 @@ describe('McpResponse', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -573,8 +571,8 @@ describe('McpResponse', () => {
context,
);
assert.ok(getTextContent(content[0]));
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -588,8 +586,8 @@ describe('McpResponse', () => {
context,
);
assert.ok(getTextContent(content[0]));
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -614,7 +612,7 @@ describe('McpResponse', () => {
);
const text = getTextContent(content[0]);
assert.ok(text.includes('<no console messages found>'));
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -660,8 +658,8 @@ describe('McpResponse network request filtering', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -683,8 +681,8 @@ describe('McpResponse network request filtering', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -706,8 +704,8 @@ describe('McpResponse network request filtering', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -730,8 +728,8 @@ describe('McpResponse network request filtering', () => {
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -755,8 +753,8 @@ describe('McpResponse network request filtering', () => {
'test',
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -777,7 +775,7 @@ describe('McpResponse network pagination', () => {
assert.ok(text.includes('Showing 1-5 of 5 (Page 1 of 1).'));
assert.ok(!text.includes('Next page:'));
assert.ok(!text.includes('Previous page:'));
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -800,7 +798,7 @@ describe('McpResponse network pagination', () => {
assert.ok(text.includes('Showing 1-10 of 30 (Page 1 of 3).'));
assert.ok(text.includes('Next page: 1'));
assert.ok(!text.includes('Previous page:'));
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -824,7 +822,7 @@ describe('McpResponse network pagination', () => {
assert.ok(text.includes('Showing 11-20 of 25 (Page 2 of 3).'));
assert.ok(text.includes('Next page: 2'));
assert.ok(text.includes('Previous page: 0'));
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -847,7 +845,7 @@ describe('McpResponse network pagination', () => {
text.includes('Invalid page number provided. Showing first page.'),
);
assert.ok(text.includes('Showing 1-2 of 5 (Page 1 of 3).'));
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -868,15 +866,15 @@ describe('McpResponse network pagination', () => {
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
+ t.assert.snapshot(getTextContent(content[0]));
const typedStructuredContent = structuredContent as {
traceSummary?: string;
traceInsights?: unknown[];
};
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(typedStructuredContent.traceSummary, null, 2),
);
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(typedStructuredContent.traceInsights, null, 2),
);
});
@@ -902,8 +900,8 @@ describe('McpResponse network pagination', () => {
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(structuredContent),
null,
@@ -931,8 +929,8 @@ describe('McpResponse network pagination', () => {
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(structuredContent),
null,
@@ -989,8 +987,8 @@ describe('extensions', () => {
context,
);
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(JSON.stringify(structuredContent, null, 2));
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(JSON.stringify(structuredContent, null, 2));
});
});
});
@@ -1032,8 +1030,8 @@ describe('lighthouse', () => {
assert.ok(text.includes('- /tmp/report.json'));
assert.ok(text.includes('- /tmp/report.html'));
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(stabilizeStructuredContent(structuredContent), null, 2),
);
});
@@ -1094,12 +1092,12 @@ describe('third-party developer tools', () => {
context,
);
const responseText = getTextContent(content[0]);
- t.assert.snapshot?.(responseText);
+ t.assert.snapshot(responseText);
assert.ok(
responseText.includes('inputSchema={"type":"object"'),
'Response should include inputSchema',
);
- t.assert.snapshot?.(JSON.stringify(structuredContent, null, 2));
+ t.assert.snapshot(JSON.stringify(structuredContent, null, 2));
},
undefined,
{categoryExperimentalThirdParty: true} as ParsedArguments,
@@ -1493,8 +1491,8 @@ describe('webmcp', () => {
context,
);
assert.ok(getTextContent(content[0]));
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(structuredContent),
null,
@@ -1558,8 +1556,8 @@ describe('webmcp', () => {
context,
);
assert.ok(getTextContent(content[0]));
- t.assert.snapshot?.(getTextContent(content[0]));
- t.assert.snapshot?.(
+ t.assert.snapshot(getTextContent(content[0]));
+ t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(structuredContent),
null,
diff --git a/tests/formatters/ConsoleFormatter.test.ts b/tests/formatters/ConsoleFormatter.test.ts
index eba9f9d2..977492b2 100644
--- a/tests/formatters/ConsoleFormatter.test.ts
+++ b/tests/formatters/ConsoleFormatter.test.ts
@@ -39,11 +39,11 @@ function formatterTestConcise(
) {
it(label + ' toString', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(formatter.toString());
+ t.assert.snapshot(formatter.toString());
});
it(label + ' toJSON', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(JSON.stringify(formatter.toJSON(), null, 2));
+ t.assert.snapshot(JSON.stringify(formatter.toJSON(), null, 2));
});
}
@@ -53,11 +53,11 @@ function formatterTestDetailed(
) {
it(label + ' toStringDetailed', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(formatter.toStringDetailed());
+ t.assert.snapshot(formatter.toStringDetailed());
});
it(label + ' toJSONDetailed', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(JSON.stringify(formatter.toJSONDetailed(), null, 2));
+ t.assert.snapshot(JSON.stringify(formatter.toJSONDetailed(), null, 2));
});
}
diff --git a/tests/formatters/HeapSnapshotFormatter.test.ts b/tests/formatters/HeapSnapshotFormatter.test.ts
index 21860060..11d0e020 100644
--- a/tests/formatters/HeapSnapshotFormatter.test.ts
+++ b/tests/formatters/HeapSnapshotFormatter.test.ts
@@ -49,7 +49,7 @@ describe('HeapSnapshotFormatter', () => {
it('formats data as CSV and sorts by retained size', t => {
const formatter = new HeapSnapshotFormatter(mockAggregates);
const result = formatter.toString();
- t.assert.snapshot?.(result);
+ t.assert.snapshot(result);
});
});
diff --git a/tests/formatters/IssueFormatter.test.ts b/tests/formatters/IssueFormatter.test.ts
index 80e96e95..605e89d7 100644
--- a/tests/formatters/IssueFormatter.test.ts
+++ b/tests/formatters/IssueFormatter.test.ts
@@ -30,11 +30,11 @@ describe('IssueFormatter', () => {
) {
it(label + ' toString', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(formatter.toString());
+ t.assert.snapshot(formatter.toString());
});
it(label + ' toJSON', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(JSON.stringify(formatter.toJSON(), null, 2));
+ t.assert.snapshot(JSON.stringify(formatter.toJSON(), null, 2));
});
}
@@ -44,11 +44,11 @@ describe('IssueFormatter', () => {
) {
it(label + ' toStringDetailed', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(formatter.toStringDetailed());
+ t.assert.snapshot(formatter.toStringDetailed());
});
it(label + ' toJSONDetailed', async t => {
const formatter = await setup(t);
- t.assert.snapshot?.(JSON.stringify(formatter.toJSONDetailed(), null, 2));
+ t.assert.snapshot(JSON.stringify(formatter.toJSONDetailed(), null, 2));
});
}
diff --git a/tests/formatters/NetworkFormatter.test.ts b/tests/formatters/NetworkFormatter.test.ts
index 3ff5b5d7..e37e5ba2 100644
--- a/tests/formatters/NetworkFormatter.test.ts
+++ b/tests/formatters/NetworkFormatter.test.ts
@@ -305,7 +305,7 @@ describe('NetworkFormatter', () => {
redactNetworkHeaders: false,
});
const result = formatter.toStringDetailed();
- t.assert.snapshot?.(result);
+ t.assert.snapshot(result);
});
it('shows saved to file message in toStringDetailed', async () => {
const request = {
diff --git a/tests/formatters/snapshotFormatter.test.ts b/tests/formatters/snapshotFormatter.test.ts
index 39385286..3f7483d4 100644
--- a/tests/formatters/snapshotFormatter.test.ts
+++ b/tests/formatters/snapshotFormatter.test.ts
@@ -191,7 +191,7 @@ describe('snapshotFormatter', () => {
});
const formatted = formatter.toString();
- t.assert.snapshot?.(formatted);
+ t.assert.snapshot(formatted);
});
it('does not include a note if the snapshot is already verbose', t => {
@@ -225,7 +225,7 @@ describe('snapshotFormatter', () => {
});
const formatted = formatter.toString();
- t.assert.snapshot?.(formatted);
+ t.assert.snapshot(formatted);
});
it('formats with DevTools data included into a snapshot', t => {
@@ -260,7 +260,7 @@ describe('snapshotFormatter', () => {
});
const formatted = formatter.toString();
- t.assert.snapshot?.(formatted);
+ t.assert.snapshot(formatted);
});
it('toJSON returns expected structure', () => {
diff --git a/tests/index.test.ts b/tests/index.test.ts
index a62e6476..d0fb4b6b 100644
--- a/tests/index.test.ts
+++ b/tests/index.test.ts
@@ -65,7 +65,7 @@ describe('e2e', () => {
name: 'list_pages',
arguments: {},
});
- t.assert.snapshot?.(JSON.stringify(result.content));
+ t.assert.snapshot(JSON.stringify(result.content));
});
});
@@ -79,7 +79,7 @@ describe('e2e', () => {
name: 'list_pages',
arguments: {},
});
- t.assert.snapshot?.(JSON.stringify(result.content));
+ t.assert.snapshot(JSON.stringify(result.content));
});
});
@@ -282,7 +282,7 @@ describe('e2e', () => {
it('returns blocked message when dialog is opened during tool execution', async t => {
await withClient(async client => {
const result = await createNewPageAndTriggerDialog(client);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
});
});
@@ -296,7 +296,7 @@ describe('e2e', () => {
},
});
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
});
});
@@ -310,7 +310,7 @@ describe('e2e', () => {
},
});
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
});
});
});
diff --git a/tests/setup.ts b/tests/setup.ts
index d48cc49d..b9a54b0d 100644
--- a/tests/setup.ts
+++ b/tests/setup.ts
@@ -9,17 +9,6 @@ import '../src/polyfill.js';
import path from 'node:path';
import {it} from 'node:test';
-if (!it.snapshot) {
- it.snapshot = {
- setResolveSnapshotPath: () => {
- // Internally empty
- },
- setDefaultSnapshotSerializers: () => {
- // Internally empty
- },
- };
-}
-
// This is run by Node when we execute the tests via the --import flag.
it.snapshot.setResolveSnapshotPath(testPath => {
// By default the snapshots go into the build directory, but we want them
diff --git a/tests/third_party_notices.test.ts b/tests/third_party_notices.test.ts
index 151609dd..c502a2ce 100644
--- a/tests/third_party_notices.test.ts
+++ b/tests/third_party_notices.test.ts
@@ -19,7 +19,7 @@ describe('THIRD_PARTY_NOTICES', () => {
const normalizedContent = content
.replace(/^Version: .*$/gm, 'Version: <VERSION>')
.replaceAll('\r', '');
- t.assert.snapshot?.(normalizedContent);
+ t.assert.snapshot(normalizedContent);
}
});
});
diff --git a/tests/tools/console.test.ts b/tests/tools/console.test.ts
index 41e310ce..b68e6160 100644
--- a/tests/tools/console.test.ts
+++ b/tests/tools/console.test.ts
@@ -71,7 +71,7 @@ describe('console', () => {
);
const formattedResponse = await response.handle('test', context);
const textContent = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(textContent);
+ t.assert.snapshot(textContent);
});
});
@@ -195,7 +195,7 @@ describe('console', () => {
'list_console_messages',
context,
);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
});
});
@@ -258,7 +258,7 @@ describe('console', () => {
context,
);
const formattedResponse = await response2.handle('test', context);
- t.assert.snapshot?.(getTextContent(formattedResponse.content[0]));
+ t.assert.snapshot(getTextContent(formattedResponse.content[0]));
});
});
it('gets issue details with request id parsing', async t => {
@@ -319,7 +319,7 @@ describe('console', () => {
.replaceAll(/ID: \d+/g, 'ID: <ID>')
.replaceAll(/reqid=\d+/g, 'reqid=<reqid>')
.replaceAll(/localhost:\d+/g, 'hostname:port');
- t.assert.snapshot?.(sanitizedText);
+ t.assert.snapshot(sanitizedText);
});
});
});
@@ -349,7 +349,7 @@ describe('console', () => {
const formattedResponse = await response.handle('test', context);
const rawText = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(rawText);
+ t.assert.snapshot(rawText);
});
});
@@ -378,7 +378,7 @@ describe('console', () => {
const formattedResponse = await response.handle('test', context);
const rawText = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(rawText);
+ t.assert.snapshot(rawText);
});
});
@@ -407,7 +407,7 @@ describe('console', () => {
const formattedResponse = await response.handle('test', context);
const rawText = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(rawText);
+ t.assert.snapshot(rawText);
});
});
@@ -436,7 +436,7 @@ describe('console', () => {
const formattedResponse = await response.handle('test', context);
const rawText = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(rawText);
+ t.assert.snapshot(rawText);
});
});
@@ -465,7 +465,7 @@ describe('console', () => {
const formattedResponse = await response.handle('test', context);
const rawText = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(rawText);
+ t.assert.snapshot(rawText);
});
});
@@ -508,7 +508,7 @@ describe('console', () => {
const formattedResponse = await response.handle('test', context);
const rawText = getTextContent(formattedResponse.content[0]);
- t.assert.snapshot?.(rawText);
+ t.assert.snapshot(rawText);
});
});
@@ -540,7 +540,7 @@ describe('console', () => {
);
const result = await response.handle('get_console_message', context);
- t.assert.snapshot?.(
+ t.assert.snapshot(
JSON.stringify(
stabilizeStructuredContent(result.structuredContent),
null,
diff --git a/tests/tools/memory.test.ts b/tests/tools/memory.test.ts
index ef98d123..7b047d66 100644
--- a/tests/tools/memory.test.ts
+++ b/tests/tools/memory.test.ts
@@ -68,7 +68,7 @@ describe('memory', () => {
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
- t.assert.snapshot?.(output);
+ t.assert.snapshot(output);
});
});
});
@@ -95,7 +95,7 @@ describe('memory', () => {
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
- t.assert.snapshot?.(output);
+ t.assert.snapshot(output);
});
});
});
@@ -125,7 +125,7 @@ describe('memory', () => {
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
- t.assert.snapshot?.(output);
+ t.assert.snapshot(output);
});
});
@@ -172,7 +172,7 @@ describe('memory', () => {
.map(c => (c.type === 'text' ? c.text : ''))
.join('\n');
- t.assert.snapshot?.(output);
+ t.assert.snapshot(output);
});
});
});
diff --git a/tests/tools/network.test.ts b/tests/tools/network.test.ts
index 14255500..eea600cf 100644
--- a/tests/tools/network.test.ts
+++ b/tests/tools/network.test.ts
@@ -55,7 +55,7 @@ describe('network', () => {
context,
);
const responseData = await response.handle('list_request', context);
- t.assert.snapshot?.(
+ t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
});
@@ -83,7 +83,7 @@ describe('network', () => {
context,
);
const responseData = await response.handle('list_request', context);
- t.assert.snapshot?.(
+ t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
});
@@ -126,7 +126,7 @@ describe('network', () => {
context,
);
const responseData = await response.handle('list_request', context);
- t.assert.snapshot?.(
+ t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
});
@@ -181,7 +181,7 @@ describe('network', () => {
);
const responseData = await response.handle('get_request', context);
- t.assert.snapshot?.(
+ t.assert.snapshot(
stabilizeResponseOutput(getTextContent(responseData.content[0])),
);
});
diff --git a/tests/tools/pages.test.ts b/tests/tools/pages.test.ts
index b8206622..99f44bb8 100644
--- a/tests/tools/pages.test.ts
+++ b/tests/tools/pages.test.ts
@@ -93,7 +93,7 @@ describe('pages', () => {
extensionId,
'<extension-id>',
);
- t.assert.snapshot?.(text);
+ t.assert.snapshot(text);
await context.uninstallExtension(extensionId);
},
{},
@@ -144,7 +144,7 @@ describe('pages', () => {
extensionId,
'<extension-id>',
);
- t.assert.snapshot?.(text);
+ t.assert.snapshot(text);
await context.uninstallExtension(extensionId);
const targets = context.browser.targets();
assertNoServiceWorkerReported(targets, extensionId);
@@ -194,7 +194,7 @@ describe('pages', () => {
extensionId,
'<extension-id>',
);
- t.assert.snapshot?.(text);
+ t.assert.snapshot(text);
await context.uninstallExtension(extensionId);
const targets = context.browser.targets();
assertNoServiceWorkerReported(targets, extensionId);
@@ -224,7 +224,7 @@ describe('pages', () => {
await listPages().handler({params: {}}, response, context);
const result = await response.handle('list_pages', context);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
});
});
@@ -400,7 +400,7 @@ describe('pages', () => {
);
const result = await response.handle('new_page', context);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
});
});
@@ -502,7 +502,7 @@ describe('pages', () => {
await closePage.handler({params: {pageId: 2}}, response, context);
const result = await response.handle('close_page', context);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
});
});
});
@@ -612,7 +612,7 @@ describe('pages', () => {
await selectPage.handler({params: {pageId: 1}}, response, context);
const result = await response.handle('select_page', context);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
});
});
@@ -891,7 +891,7 @@ describe('pages', () => {
);
const result = await response.handle('navigate_page', context);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
});
});
});
@@ -1083,7 +1083,7 @@ describe('pages', () => {
);
const result = await response.handle('resize_page', context);
- t.assert.snapshot?.(JSON.stringify(result));
+ t.assert.snapshot(JSON.stringify(result));
await dialog.dismiss();
});
});
diff --git a/tests/tools/slim/tools.test.ts b/tests/tools/slim/tools.test.ts
index f17adc95..efbb8cd0 100644
--- a/tests/tools/slim/tools.test.ts
+++ b/tests/tools/slim/tools.test.ts
@@ -26,7 +26,7 @@ describe('slim', () => {
response,
context,
);
- t.assert.snapshot?.(response.responseLines.join('\n'));
+ t.assert.snapshot(response.responseLines.join('\n'));
});
});
@@ -42,7 +42,7 @@ describe('slim', () => {
response,
context,
);
- t.assert.snapshot?.(response.responseLines.join('\n'));
+ t.assert.snapshot(response.responseLines.join('\n'));
});
});
@@ -62,7 +62,7 @@ describe('slim', () => {
'Hello MCP',
);
assert(!response.includePages);
- t.assert.snapshot?.(response.responseLines.join('\n'));
+ t.assert.snapshot(response.responseLines.join('\n'));
});
});
diff --git a/tests/trace-processing/parse.test.ts b/tests/trace-processing/parse.test.ts
index d54ff24b..c9b87434 100644
--- a/tests/trace-processing/parse.test.ts
+++ b/tests/trace-processing/parse.test.ts
@@ -37,7 +37,7 @@ describe('Trace parsing', async () => {
assert.ok(result?.insights);
const output = getTraceSummary(result);
- t.assert.snapshot?.(output);
+ t.assert.snapshot(output);
});
it('will return a message if there is an error', async () => {