-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathparse.test.ts
More file actions
44 lines (40 loc) · 1.32 KB
/
parse.test.ts
File metadata and controls
44 lines (40 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {describe, it} from 'node:test';
import assert from 'node:assert';
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.',
});
});
});