forked from getsentry/sentry-javascript-bundler-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-id-injection.test.ts
More file actions
58 lines (48 loc) · 1.88 KB
/
debug-id-injection.test.ts
File metadata and controls
58 lines (48 loc) · 1.88 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* eslint-disable jest/no-standalone-expect */
/* eslint-disable jest/expect-expect */
import childProcess from "child_process";
import path from "path";
function checkBundle(bundlePath1: string, bundlePath2: string): string[] {
const process1Output = childProcess.execSync(`node ${bundlePath1}`, { encoding: "utf-8" });
const debugIdMap1 = JSON.parse(process1Output) as Record<string, string>;
const debugIds1 = Object.values(debugIdMap1);
expect(debugIds1.length).toBeGreaterThan(0);
expect(debugIds1).toContainEqual(
expect.stringMatching(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)
);
expect(Object.keys(debugIdMap1)[0]).toContain("Error");
const process2Output = childProcess.execSync(`node ${bundlePath2}`, { encoding: "utf-8" });
const debugIdMap2 = JSON.parse(process2Output) as Record<string, string>;
const debugIds2 = Object.values(debugIdMap2);
expect(debugIds2.length).toBeGreaterThan(0);
expect(debugIds2).toContainEqual(
expect.stringMatching(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)
);
expect(Object.keys(debugIdMap2)[0]).toContain("Error");
expect(debugIds1).not.toEqual(debugIds2);
return [...debugIds1, ...debugIds2];
}
test("esbuild bundle", () => {
checkBundle(
path.join(__dirname, "out", "esbuild", "bundle1.js"),
path.join(__dirname, "out", "esbuild", "bundle2.js")
);
});
test("rollup bundle", () => {
checkBundle(
path.join(__dirname, "out", "rollup", "bundle1.js"),
path.join(__dirname, "out", "rollup", "bundle2.js")
);
});
test("vite bundle", () => {
checkBundle(
path.join(__dirname, "out", "vite", "bundle1.js"),
path.join(__dirname, "out", "vite", "bundle2.js")
);
});
test("webpack 5 bundle", () => {
checkBundle(
path.join(__dirname, "out", "webpack", "bundle1.js"),
path.join(__dirname, "out", "webpack", "bundle2.js")
);
});