Skip to content

Commit 5aea4f8

Browse files
committed
Add dont-mess-up-user-code tests
1 parent b314161 commit 5aea4f8

29 files changed

Lines changed: 368 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const sentryConfig = {
2+
telemetry: false,
3+
release: { name: "I am release!", create: false },
4+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as esbuild from "esbuild";
2+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
3+
import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/index.js"],
7+
bundle: true,
8+
outfile: "./out/dont-mess-up-user-code/index.js",
9+
minify: false,
10+
format: "iife",
11+
sourcemap: true,
12+
plugins: [sentryEsbuildPlugin(sentryConfig)],
13+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"index.js": "(() => {
9+
// _sentry-injection-stub
10+
!(function() {
11+
try {
12+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
13+
e.SENTRY_RELEASE = { id: "I am release!" };
14+
} catch (e2) {
15+
}
16+
})();
17+
18+
// sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
19+
!(function() {
20+
try {
21+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
22+
var n = new e.Error().stack;
23+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000");
24+
} catch (e2) {
25+
}
26+
})();
27+
28+
// src/import.js
29+
console.log("I am import!");
30+
31+
// src/index.js
32+
console.log("I am index!");
33+
34+
// src/index.js?sentryDebugIdProxy=true
35+
var index_default = void 0;
36+
})();
37+
//# sourceMappingURL=index.js.map
38+
",
39+
"index.js.map": "{"version":3,"sources":["../../_sentry-injection-stub","sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000","../../src/import.js","../../src/index.js","../../src/index.js"],"sourcesContent":["!function(){try{var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeof global?global:\\"undefined\\"!=typeof globalThis?globalThis:\\"undefined\\"!=typeof self?self:{};e.SENTRY_RELEASE={id:\\"I am release!\\"};}catch(e){}}();","!function(){try{var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeof global?global:\\"undefined\\"!=typeof globalThis?globalThis:\\"undefined\\"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\\"00000000-0000-0000-0000-000000000000\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-00000000-0000-0000-0000-000000000000\\");}catch(e){}}();","// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n","\\n import \\"_sentry-debug-id-injection-stub\\";\\n import * as OriginalModule from \\"./src/index.js\\";\\n export default OriginalModule.default;\\n export * from \\"./src/index.js\\";"],"mappings":";;AAAA,IAAC,WAAU;AAAC,QAAG;AAAC,UAAI,IAAE,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,aAAW,aAAW,eAAa,OAAO,OAAK,OAAK,CAAC;AAAE,QAAE,iBAAe,EAAC,IAAG,gBAAe;AAAA,IAAE,SAAOA,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACAxN,IAAC,WAAU;AAAC,QAAG;AAAC,UAAI,IAAE,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,SAAO,SAAO,eAAa,OAAO,aAAW,aAAW,eAAa,OAAO,OAAK,OAAK,CAAC;AAAE,UAAI,IAAG,IAAI,EAAE,QAAO;AAAM,YAAI,EAAE,kBAAgB,EAAE,mBAAiB,CAAC,GAAE,EAAE,gBAAgB,CAAC,IAAE,wCAAuC,EAAE,2BAAyB;AAAA,IAAoD,SAAOC,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACCnY,UAAQ,IAAI,cAAc;;;ACE1B,UAAQ,IAAI,aAAa;;;ACAX,MAAO,gBAAuB;","names":["e","e"]}",
40+
}
41+
`);
42+
43+
const output = runFileInNode("index.js");
44+
expect(output).toContain("I am import!");
45+
expect(output).toContain("I am index!");
46+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line no-console
2+
console.log("I am import!");
3+
4+
export {};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import "./import";
2+
3+
// eslint-disable-next-line no-console
4+
console.log("I am index!");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2+
import { defineConfig } from "rolldown";
3+
import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js";
4+
5+
export default defineConfig({
6+
input: "src/index.js",
7+
output: {
8+
file: "out/dont-mess-up-user-code/index.js",
9+
sourcemap: true,
10+
},
11+
plugins: [sentryRollupPlugin(sentryConfig)],
12+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"index.js": "//#region src/import.js
9+
(function() {
10+
try {
11+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
12+
e.SENTRY_RELEASE = { id: "I am release!" };
13+
var n = new e.Error().stack;
14+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000");
15+
} catch (e) {}
16+
})();
17+
console.log("I am import!");
18+
//#endregion
19+
//#region src/index.js
20+
console.log("I am index!");
21+
//#endregion
22+
23+
//# sourceMappingURL=index.js.map",
24+
"index.js.map": "{"version":3,"file":"index.js","names":[],"sources":["../../src/import.js","../../src/index.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"I am import!\\");\\n\\nexport {};\\n","import \\"./import\\";\\n\\n// eslint-disable-next-line no-console\\nconsole.log(\\"I am index!\\");\\n"],"mappings":";;;;;;;;;AACA,QAAQ,IAAI,eAAe;;;ACE3B,QAAQ,IAAI,cAAc"}",
25+
}
26+
`);
27+
28+
const output = runFileInNode("index.js");
29+
expect(output).toContain("I am import!");
30+
expect(output).toContain("I am index!");
31+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line no-console
2+
console.log("I am import!");
3+
4+
export {};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import "./import";
2+
3+
// eslint-disable-next-line no-console
4+
console.log("I am index!");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2+
import { defineConfig } from "rollup";
3+
import { sentryConfig } from "../configs/dont-mess-up-user-code.config.js";
4+
5+
export default defineConfig({
6+
input: "src/index.js",
7+
output: {
8+
file: "out/dont-mess-up-user-code/index.js",
9+
sourcemap: true,
10+
},
11+
plugins: [sentryRollupPlugin(sentryConfig)],
12+
});

0 commit comments

Comments
 (0)