Skip to content

Commit 76b9504

Browse files
author
Luca Forstner
committed
Add test
1 parent 2915be0 commit 76b9504

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Simply output the metadata to the console so it can be checked in a test
2+
// eslint-disable-next-line no-console, @typescript-eslint/no-unsafe-member-access
3+
console.log(JSON.stringify(global.SENTRY_RELEASE.id));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* eslint-disable jest/no-standalone-expect */
2+
/* eslint-disable jest/expect-expect */
3+
import { execSync } from "child_process";
4+
import path from "path";
5+
import { testIfNodeMajorVersionIsLessThan18 } from "../../utils/testIf";
6+
7+
function checkBundle(bundlePath: string): void {
8+
const output = execSync(`node ${bundlePath}`, { encoding: "utf-8" });
9+
expect(output).toBe('i am a dangerous release value because I contain a "');
10+
}
11+
12+
describe("Properly escapes release values before injecting", () => {
13+
testIfNodeMajorVersionIsLessThan18("webpack 4 bundle", () => {
14+
checkBundle(path.join(__dirname, "out", "webpack4", "bundle.js"));
15+
});
16+
17+
test("webpack 5 bundle", () => {
18+
checkBundle(path.join(__dirname, "out", "webpack5", "bundle.js"));
19+
});
20+
21+
test("esbuild bundle", () => {
22+
checkBundle(path.join(__dirname, "out", "esbuild", "bundle.js"));
23+
});
24+
25+
test("rollup bundle", () => {
26+
checkBundle(path.join(__dirname, "out", "rollup", "bundle.js"));
27+
});
28+
29+
test("vite bundle", () => {
30+
checkBundle(path.join(__dirname, "out", "vite", "bundle.js"));
31+
});
32+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as path from "path";
2+
import { createCjsBundles } from "../../utils/create-cjs-bundles";
3+
4+
const outputDir = path.resolve(__dirname, "out");
5+
6+
createCjsBundles(
7+
{
8+
bundle: path.resolve(__dirname, "input", "bundle.js"),
9+
},
10+
outputDir,
11+
{
12+
release: { name: 'i am a dangerous release value because I contain a "' },
13+
},
14+
["webpack4", "webpack5", "esbuild", "rollup", "vite"]
15+
);

0 commit comments

Comments
 (0)