Skip to content

Commit 10a3c53

Browse files
committed
integration tests
1 parent f852b55 commit 10a3c53

File tree

14 files changed

+199
-162
lines changed

14 files changed

+199
-162
lines changed

packages/bundler-plugin-core/src/debug-id-upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function createDebugIdUploadFunction({
168168
});
169169

170170
await cliInstance.releases.uploadSourceMaps(
171-
releaseName ?? "undefined", // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
171+
releaseName ?? "undefined", // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
172172
{
173173
include: [
174174
{

packages/integration-tests/fixtures/error-no-handler/error-no-handler.test.ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/integration-tests/fixtures/error-no-handler/setup.ts

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
2+
import { build } from "esbuild";
3+
import pluginOptions from "./plugin-options";
4+
import path from "path";
5+
6+
build({
7+
entryPoints: [path.join(__dirname, "input", "bundle.js")],
8+
outdir: "./out/esbuild",
9+
plugins: [sentryEsbuildPlugin(pluginOptions)],
10+
minify: true,
11+
bundle: true,
12+
format: "cjs",
13+
sourcemap: true,
14+
}).catch((e) => {
15+
// eslint-disable-next-line no-console
16+
console.error(e);
17+
process.exit(1);
18+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2+
import * as path from "path";
3+
import * as rollup from "rollup";
4+
import pluginOptions from "./plugin-options";
5+
6+
rollup
7+
.rollup({
8+
input: {
9+
index: path.join(__dirname, "input", "bundle.js"),
10+
},
11+
plugins: [sentryRollupPlugin(pluginOptions)],
12+
})
13+
.then((bundle) =>
14+
bundle.write({
15+
dir: path.join(__dirname, "out", "rollup"),
16+
format: "cjs",
17+
exports: "named",
18+
})
19+
)
20+
.catch((e) => {
21+
// eslint-disable-next-line no-console
22+
console.error(e);
23+
process.exit(1);
24+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { sentryVitePlugin } from "@sentry/vite-plugin";
2+
import * as path from "path";
3+
import * as vite from "vite";
4+
import pluginOptions from "./plugin-options";
5+
6+
vite
7+
.build({
8+
clearScreen: false,
9+
build: {
10+
outDir: path.join(__dirname, "out", "vite"),
11+
rollupOptions: {
12+
input: {
13+
index: path.join(__dirname, "input", "bundle.js"),
14+
},
15+
output: {
16+
format: "cjs",
17+
entryFileNames: "[name].js",
18+
},
19+
},
20+
},
21+
plugins: [sentryVitePlugin(pluginOptions)],
22+
})
23+
.catch((e) => {
24+
// eslint-disable-next-line no-console
25+
console.error(e);
26+
process.exit(1);
27+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import * as path from "path";
3+
import { default as webpack4 } from "webpack4";
4+
import pluginOptions from "./plugin-options";
5+
6+
webpack4(
7+
{
8+
devtool: "source-map",
9+
cache: false,
10+
entry: {
11+
index: path.join(__dirname, "input", "bundle.js"),
12+
},
13+
output: {
14+
path: path.join(__dirname, "out", "webpack4"),
15+
libraryTarget: "commonjs",
16+
},
17+
mode: "production",
18+
target: "node", // needed for webpack 4 so we can access node api
19+
plugins: [sentryWebpackPlugin(pluginOptions)],
20+
},
21+
(err) => {
22+
if (err) {
23+
process.exit(1);
24+
}
25+
}
26+
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import * as path from "path";
3+
import { webpack as webpack5 } from "webpack5";
4+
import pluginOptions from "./plugin-options";
5+
6+
webpack5(
7+
{
8+
devtool: "source-map",
9+
cache: false,
10+
entry: {
11+
index: path.join(__dirname, "input", "bundle.js"),
12+
},
13+
output: {
14+
path: path.join(__dirname, "out", "webpack5"),
15+
library: {
16+
type: "commonjs",
17+
},
18+
},
19+
mode: "production",
20+
plugins: [sentryWebpackPlugin(pluginOptions)],
21+
},
22+
(err) => {
23+
if (err) {
24+
process.exit(1);
25+
}
26+
}
27+
);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* eslint-disable jest/no-standalone-expect */
2+
/* eslint-disable jest/expect-expect */
3+
import path from "path";
4+
import { spawn } from "child_process";
5+
6+
jest.setTimeout(10_000);
7+
8+
describe("Error throwing by default (no errorHandler)", () => {
9+
const FAKE_SENTRY_PORT = "9876";
10+
11+
const sentryServer = spawn("node", ["fakeSentry.js"], {
12+
cwd: __dirname,
13+
stdio: "ignore", // <-- set to "inherit" to get server logs. Deactivated to avoid test logs.
14+
env: { ...process.env, FAKE_SENTRY_PORT },
15+
});
16+
17+
beforeAll(async () => {
18+
await new Promise<void>((resolve) =>
19+
sentryServer.on("spawn", () => {
20+
resolve();
21+
})
22+
);
23+
});
24+
25+
afterAll(() => {
26+
sentryServer.kill();
27+
});
28+
29+
test.each(["vite", "rollup", "webpack5", "webpack4", "esbuild"])(
30+
"doesn't throw when Sentry server responds with error code for %s",
31+
async (bundler) => {
32+
const buildProcess = spawn("yarn", ["ts-node", path.join(__dirname, `build-${bundler}.ts`)], {
33+
env: { ...process.env, FAKE_SENTRY_PORT },
34+
stdio: "ignore", // <-- set to "inherit" to get build output. Deactivated to avoid spamming test logs.
35+
});
36+
37+
const exitCode = await new Promise<number>((resolve, reject) => {
38+
buildProcess.on("exit", (code) => {
39+
resolve(code ?? 99);
40+
});
41+
42+
buildProcess.on("error", (err) => {
43+
reject(err);
44+
});
45+
});
46+
47+
expect(exitCode).toBe(0);
48+
49+
buildProcess.kill();
50+
}
51+
);
52+
});
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { createServer } from "http";
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const { createServer } = require("http");
23

34
const port = process.env["FAKE_SENTRY_PORT"] || 3000;
45

56
const server = createServer((req, res) => {
7+
console.log("[SANTRY] incoming request", req.url);
68
res.statusCode = 503;
79
res.end("Error: Santry unreachable");
810
});
911

1012
server.listen(port, () => {
1113
// eslint-disable-next-line no-console
12-
console.log(`Santry running on http://localhost:${port}/`);
14+
console.log(`[SANTRY] running on http://localhost:${port}/`);
1315
});

0 commit comments

Comments
 (0)