Skip to content

Commit 9fa5191

Browse files
authored
test: Add esbuild integration tests (#911)
1 parent aa73f53 commit 9fa5191

35 files changed

+805
-2
lines changed
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/after-upload-deletion.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/basic.js"],
7+
bundle: true,
8+
outfile: "./out/after-upload-deletion/basic.js",
9+
minify: false,
10+
format: "iife",
11+
sourcemap: true,
12+
plugins: [sentryEsbuildPlugin(sentryConfig)],
13+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
"basic.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: "CURRENT_SHA" };
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/basic.js
29+
console.log("hello world");
30+
31+
// src/basic.js?sentryDebugIdProxy=true
32+
var basic_default = void 0;
33+
})();
34+
//# sourceMappingURL=basic.js.map
35+
",
36+
}
37+
`);
38+
39+
const output = runFileInNode("basic.js");
40+
expect(output).toBe("hello world\n");
41+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as esbuild from "esbuild";
2+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
3+
import { sentryConfig } from "../configs/application-key.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/basic.js"],
7+
bundle: true,
8+
outfile: "./out/application-key/application-key.js",
9+
minify: false,
10+
format: "iife",
11+
plugins: [sentryEsbuildPlugin(sentryConfig)],
12+
});
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
"application-key.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: "CURRENT_SHA" };
14+
e._sentryModuleMetadata = e._sentryModuleMetadata || {}, e._sentryModuleMetadata[new e.Error().stack] = (function(e2) {
15+
for (var n = 1; n < arguments.length; n++) {
16+
var a = arguments[n];
17+
if (null != a) for (var t in a) a.hasOwnProperty(t) && (e2[t] = a[t]);
18+
}
19+
return e2;
20+
})({}, e._sentryModuleMetadata[new e.Error().stack], { "_sentryBundlerPluginAppKey:1234567890abcdef": true });
21+
} catch (e2) {
22+
}
23+
})();
24+
25+
// sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
26+
!(function() {
27+
try {
28+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
29+
var n = new e.Error().stack;
30+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "00000000-0000-0000-0000-000000000000", e._sentryDebugIdIdentifier = "sentry-dbid-00000000-0000-0000-0000-000000000000");
31+
} catch (e2) {
32+
}
33+
})();
34+
35+
// src/basic.js
36+
console.log("hello world");
37+
38+
// src/basic.js?sentryDebugIdProxy=true
39+
var basic_default = void 0;
40+
})();
41+
",
42+
}
43+
`);
44+
45+
const output = runFileInNode("application-key.js");
46+
expect(output).toBe("hello world\n");
47+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as esbuild from "esbuild";
2+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
3+
import { sentryConfig } from "../configs/basic-release-disabled.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/basic.js"],
7+
bundle: true,
8+
outfile: "./out/basic-release-disabled/basic-release-disabled.js",
9+
minify: false,
10+
format: "iife",
11+
plugins: [sentryEsbuildPlugin(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+
"basic-release-disabled.js": "(() => {
9+
// sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=00000000-0000-0000-0000-000000000000
10+
!(function() {
11+
try {
12+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
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 (e2) {
16+
}
17+
})();
18+
19+
// src/basic.js
20+
console.log("hello world");
21+
22+
// src/basic.js?sentryDebugIdProxy=true
23+
var basic_default = void 0;
24+
})();
25+
",
26+
}
27+
`);
28+
29+
const output = runFileInNode("basic-release-disabled.js");
30+
expect(output).toBe("hello world\n");
31+
});
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/basic-sourcemaps.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/basic.js"],
7+
bundle: true,
8+
outfile: "./out/basic-sourcemaps/basic-sourcemaps.js",
9+
minify: false,
10+
format: "iife",
11+
sourcemap: true,
12+
plugins: [sentryEsbuildPlugin(sentryConfig)],
13+
});
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
"basic-sourcemaps.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: "CURRENT_SHA" };
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/basic.js
29+
console.log("hello world");
30+
31+
// src/basic.js?sentryDebugIdProxy=true
32+
var basic_default = void 0;
33+
})();
34+
//# sourceMappingURL=basic-sourcemaps.js.map
35+
",
36+
"basic-sourcemaps.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/basic.js","../../src/basic.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:\\"CURRENT_SHA\\"};}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(\\"hello world\\");\\n","\\n import \\"_sentry-debug-id-injection-stub\\";\\n import * as OriginalModule from \\"./src/basic.js\\";\\n export default OriginalModule.default;\\n export * from \\"./src/basic.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,2CAA0C;AAAA,IAAE,SAAOA,IAAE;AAAA,IAAC;AAAA,EAAC,GAAE;;;ACAnP,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,aAAa;;;ACEX,MAAO,gBAAuB;","names":["e","e"]}",
37+
"sentry-cli-mock.json": "["releases","new","CURRENT_SHA"],
38+
["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
39+
["releases","finalize","CURRENT_SHA"],
40+
["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
41+
",
42+
}
43+
`);
44+
45+
const output = runFileInNode("basic-sourcemaps.js");
46+
expect(output).toBe("hello world\n");
47+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as esbuild from "esbuild";
2+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
3+
import { sentryConfig } from "../configs/basic.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/basic.js"],
7+
bundle: true,
8+
outfile: "./out/basic/basic.js",
9+
minify: false,
10+
format: "iife",
11+
plugins: [sentryEsbuildPlugin(sentryConfig)],
12+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
"basic.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: "CURRENT_SHA" };
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/basic.js
29+
console.log("hello world");
30+
31+
// src/basic.js?sentryDebugIdProxy=true
32+
var basic_default = void 0;
33+
})();
34+
",
35+
"sentry-cli-mock.json": "["releases","new","CURRENT_SHA"],
36+
["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
37+
["releases","finalize","CURRENT_SHA"],
38+
["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
39+
",
40+
}
41+
`);
42+
43+
const output = runFileInNode("basic.js");
44+
expect(output).toBe("hello world\n");
45+
});

0 commit comments

Comments
 (0)