forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeasure-copilotchat.test.mjs
More file actions
43 lines (40 loc) · 1.63 KB
/
Copy pathmeasure-copilotchat.test.mjs
File metadata and controls
43 lines (40 loc) · 1.63 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
// Standalone Node test (not vitest) — the script under test calls esbuild,
// which trips vitest's jsdom env probe, and the package-wide vitest setup uses
// jsdom-only globals. Running with `node --test` keeps this isolated.
//
// Invoked from package.json `test:scripts` and the chained `test` command.
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { measureBundle } from "../measure-copilotchat.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const fixtureDir = path.join(here, "fixtures");
const fixtureEntry = path.join(fixtureDir, "tiny-entry.js");
describe("measureBundle", () => {
it("bundles a tiny CopilotChat fixture and returns a positive gzip total", async () => {
const result = await measureBundle({
entryModule: fixtureEntry,
pkgRoot: fixtureDir,
});
assert.ok(result.totalBytes > 0, "totalBytes should be > 0");
// Trivial fixture; a sane upper bound guards against accidental inclusion
// of huge externals or the loader stubs regressing.
assert.ok(
result.totalBytes < 50_000,
`totalBytes should be < 50_000, got ${result.totalBytes}`,
);
assert.ok(result.outputCount >= 1, "outputCount should be >= 1");
});
it("returns a deterministic gzip total across two runs", async () => {
const a = await measureBundle({
entryModule: fixtureEntry,
pkgRoot: fixtureDir,
});
const b = await measureBundle({
entryModule: fixtureEntry,
pkgRoot: fixtureDir,
});
assert.equal(b.totalBytes, a.totalBytes);
});
});