项目文件夹

文件
Nikolay Vitkov bede4fbdfa chore: install HostBindingAdapter (#2186)
This PR introduces the HostBindingAdapter to utilize the functions
usually available to DevTools.
Additionally I moved all the DevTools related files under a `devtools`
directory to better separate the extractor logic.
The patch scripts for DevTools were moved under a function to remove the
side-effect nature of the file.
Now gets called in a the creation of the McpContext (and a before hook
in test.)
2026-06-09 12:18:25 +00:00

48 行
1.3 KiB
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import assert from 'node:assert';
import {describe, it} from 'node:test';
import {
getTraceSummary,
parseRawTraceBuffer,
} from '../../src/trace-processing/parse.js';
import {loadTraceAsBuffer} from './fixtures/load.js';
describe('Trace parsing', async () => {
it('can parse a Uint8Array from Tracing.stop())', async () => {
const rawData = loadTraceAsBuffer('basic-trace.json.gz');
const result = await parseRawTraceBuffer(rawData);
if ('error' in result) {
assert.fail(`Unexpected parse failure: ${result.error}`);
}
assert.ok(result?.parsedTrace);
assert.ok(result?.insights);
});
it('can format results of a trace', async t => {
const rawData = loadTraceAsBuffer('web-dev-with-commit.json.gz');
const result = await parseRawTraceBuffer(rawData);
if ('error' in result) {
assert.fail(`Unexpected parse failure: ${result.error}`);
}
assert.ok(result?.parsedTrace);
assert.ok(result?.insights);
const output = getTraceSummary(result);
t.assert.snapshot(output);
});
it('will return a message if there is an error', async () => {
const result = await parseRawTraceBuffer(undefined);
assert.deepEqual(result, {
error: 'No buffer was provided.',
});
});
});