|
1 | | -import path from "path"; |
2 | | - |
3 | | -import * as rollup from "rollup"; |
4 | 1 | import { sentryRollupPlugin } from "@sentry/rollup-plugin"; |
5 | 2 |
|
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"; |
11 | 4 |
|
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 }>; |
16 | 12 |
|
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); |
28 | 14 |
|
29 | | - expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(false); |
30 | | - delete process.env["SENTRY_NODE_ENV"]; |
| 15 | + expect(debugIdUploadPlugin).toBeUndefined(); |
31 | 16 | }); |
32 | 17 |
|
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 }>; |
37 | 22 |
|
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); |
46 | 24 |
|
47 | | - expect(gbl.__SENTRY_DEBUG_ID_UPLOAD_TEST__).toBe(true); |
48 | | - delete process.env["SENTRY_NODE_ENV"]; |
| 25 | + expect(debugIdUploadPlugin).toBeDefined(); |
49 | 26 | }); |
0 commit comments