Skip to content

Commit 0d2cde8

Browse files
committed
test: Add esbuild integration tests
1 parent 1e6cfc7 commit 0d2cde8

33 files changed

+787
-0
lines changed
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/after-upload-deletion.config.js";
4+
5+
await esbuild.build({
6+
entryPoints: ["./src/basic.js"],
7+
bundle: true,
8+
outfile: "./out/after-upload-deletion/after-upload-deletion.js",
9+
minify: false,
10+
format: "iife",
11+
plugins: [sentryEsbuildPlugin(sentryConfig)],
12+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode, createTempDir }) => {
5+
const tempUploadDir = createTempDir();
6+
7+
runBundler({ SENTRY_UPLOAD_DIR: tempUploadDir });
8+
expect(readOutputFiles()).toMatchInlineSnapshot(`
9+
{
10+
"after-upload-deletion.js": "(() => {
11+
// _sentry-injection-stub
12+
!(function() {
13+
try {
14+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
15+
e.SENTRY_RELEASE = { id: "CURRENT_SHA" };
16+
} catch (e2) {
17+
}
18+
})();
19+
20+
// sentry-debug-id-stub:_sentry-debug-id-injection-stub?sentry-module-id=0b47a7df-9bd6-49af-b000-120af50210e7
21+
!(function() {
22+
try {
23+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {};
24+
var n = new e.Error().stack;
25+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "22bc3889-65fe-4261-864b-14743cb882fc", e._sentryDebugIdIdentifier = "sentry-dbid-22bc3889-65fe-4261-864b-14743cb882fc");
26+
} catch (e2) {
27+
}
28+
})();
29+
30+
// src/basic.js
31+
console.log("hello world");
32+
33+
// src/basic.js?sentryDebugIdProxy=true
34+
var basic_default = void 0;
35+
})();
36+
",
37+
}
38+
`);
39+
40+
const output = runFileInNode("after-upload-deletion.js");
41+
expect(output).toBe("hello world\n");
42+
});
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=36ab4956-8bc7-41fe-ae11-ff1b128e260c
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] = "64bc859a-c7c1-4c92-a0e8-426b986498f6", e._sentryDebugIdIdentifier = "sentry-dbid-64bc859a-c7c1-4c92-a0e8-426b986498f6");
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=67d855c1-c1ce-4878-b7df-5e1d3a845acd
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] = "6127d709-823a-434f-a0b5-84ffddc24a46", e._sentryDebugIdIdentifier = "sentry-dbid-6127d709-823a-434f-a0b5-84ffddc24a46");
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=a0ace079-bed9-42d5-843c-9a9e9069b050
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] = "f0a38e67-9616-41ca-8594-2c05add42ced", e._sentryDebugIdIdentifier = "sentry-dbid-f0a38e67-9616-41ca-8594-2c05add42ced");
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=a0ace079-bed9-42d5-843c-9a9e9069b050","../../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]=\\"f0a38e67-9616-41ca-8594-2c05add42ced\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-f0a38e67-9616-41ca-8594-2c05add42ced\\");}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=c8279241-c5a1-4eac-a18d-a76dafa5eebb
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] = "18c35f84-a9e2-4ff3-8f86-03b6125dfff4", e._sentryDebugIdIdentifier = "sentry-dbid-18c35f84-a9e2-4ff3-8f86-03b6125dfff4");
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)