Skip to content

Commit af20339

Browse files
committed
simplify test
1 parent 2074464 commit af20339

File tree

2 files changed

+16
-45
lines changed

2 files changed

+16
-45
lines changed
Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,26 @@
1-
import path from "path";
2-
3-
import * as rollup from "rollup";
41
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
52

6-
function getGlobalWithDebugIdUploads(): typeof global & {
7-
__SENTRY_DEBUG_ID_UPLOAD_TEST__?: boolean;
8-
} {
9-
return global;
10-
}
3+
const debugIdUploadPluginName = "sentry-rollup-debug-id-upload-plugin";
114

12-
test("should not call upload plugin when sourcemaps are disabled", async () => {
13-
process.env["SENTRY_NODE_ENV"] = "test";
14-
const gbl = getGlobalWithDebugIdUploads();
15-
gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = false;
5+
test("should not call upload plugin when sourcemaps are disabled", () => {
6+
const plugins = sentryRollupPlugin({
7+
telemetry: false,
8+
sourcemaps: {
9+
disable: true,
10+
},
11+
}) as Array<{ name: string }>;
1612

17-
await rollup.rollup({
18-
input: { bundle1: path.resolve(__dirname, "input", "bundle.js") },
19-
plugins: [
20-
sentryRollupPlugin({
21-
telemetry: false,
22-
sourcemaps: {
23-
disable: true,
24-
},
25-
}),
26-
],
27-
});
13+
const debugIdUploadPlugin = plugins.find((plugin) => plugin.name === debugIdUploadPluginName);
2814

29-
expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(false);
30-
delete process.env["SENTRY_NODE_ENV"];
15+
expect(debugIdUploadPlugin).toBeUndefined();
3116
});
3217

33-
test("should call upload plugin when sourcemaps are enabled", async () => {
34-
process.env["SENTRY_NODE_ENV"] = "test";
35-
const gbl = getGlobalWithDebugIdUploads();
36-
gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = false;
18+
test("should call upload plugin when sourcemaps are enabled", () => {
19+
const plugins = sentryRollupPlugin({
20+
telemetry: false,
21+
}) as Array<{ name: string }>;
3722

38-
await rollup.rollup({
39-
input: { bundle1: path.resolve(__dirname, "input", "bundle.js") },
40-
plugins: [
41-
sentryRollupPlugin({
42-
telemetry: false,
43-
}),
44-
],
45-
});
23+
const debugIdUploadPlugin = plugins.find((plugin) => plugin.name === debugIdUploadPluginName);
4624

47-
expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(true);
48-
delete process.env["SENTRY_NODE_ENV"];
25+
expect(debugIdUploadPlugin).toBeDefined();
4926
});

packages/rollup-plugin/src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ function rollupDebugIdUploadPlugin(
4545
logger: Logger,
4646
createDependencyOnBuildArtifacts: () => () => void
4747
): UnpluginOptions {
48-
// Only for testing purposes
49-
if (process.env["SENTRY_NODE_ENV"] === "test") {
50-
if ("__SENTRY_DEBUG_ID_UPLOAD_TEST__" in global) {
51-
global.__SENTRY_DEBUG_ID_UPLOAD_TEST__ = true;
52-
}
53-
}
5448
return {
5549
name: "sentry-rollup-debug-id-upload-plugin",
5650
rollup: createRollupDebugIdUploadHooks(upload, logger, createDependencyOnBuildArtifacts),

0 commit comments

Comments
 (0)