Skip to content

Commit b314161

Browse files
committed
Add after-upload-deletion-promise tests
1 parent efe8d20 commit b314161

17 files changed

Lines changed: 281 additions & 0 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Config that uses a Promise for filesToDeleteAfterUpload
2+
// This tests that the plugin can handle async file deletion patterns
3+
export function getSentryConfig(outDir) {
4+
const fileDeletionPromise = new Promise((resolve) => {
5+
setTimeout(() => {
6+
resolve([`${outDir}/basic.js.map`]);
7+
}, 100);
8+
});
9+
10+
return {
11+
telemetry: false,
12+
sourcemaps: {
13+
filesToDeleteAfterUpload: fileDeletionPromise,
14+
},
15+
};
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as esbuild from "esbuild";
2+
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
3+
import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js";
4+
5+
const outDir = "./out/after-upload-deletion-promise";
6+
7+
await esbuild.build({
8+
entryPoints: ["./src/basic.js"],
9+
bundle: true,
10+
outfile: `${outDir}/basic.js`,
11+
minify: false,
12+
format: "iife",
13+
sourcemap: true,
14+
plugins: [sentryEsbuildPlugin(getSentryConfig(outDir))],
15+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
import { existsSync } from "node:fs";
4+
import { join } from "node:path";
5+
6+
test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => {
7+
runBundler();
8+
9+
// Verify the JS file exists and works
10+
const output = runFileInNode("basic.js");
11+
expect(output).toBe("hello world\n");
12+
13+
// Verify the sourcemap was deleted (by the Promise)
14+
const sourcemapPath = join(outDir, "basic.js.map");
15+
expect(existsSync(sourcemapPath)).toBe(false);
16+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2+
import { defineConfig } from "rolldown";
3+
import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js";
4+
5+
const outDir = "out/after-upload-deletion-promise";
6+
7+
export default defineConfig({
8+
input: "src/basic.js",
9+
output: {
10+
file: `${outDir}/basic.js`,
11+
sourcemap: true,
12+
},
13+
plugins: [sentryRollupPlugin(getSentryConfig(outDir))],
14+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
import { existsSync } from "node:fs";
4+
import { join } from "node:path";
5+
6+
test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => {
7+
runBundler();
8+
9+
// Verify the JS file exists and works
10+
const output = runFileInNode("basic.js");
11+
expect(output).toBe("hello world\n");
12+
13+
// Verify the sourcemap was deleted (by the Promise)
14+
const sourcemapPath = join(outDir, "basic.js.map");
15+
expect(existsSync(sourcemapPath)).toBe(false);
16+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2+
import { defineConfig } from "rollup";
3+
import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js";
4+
5+
const outDir = "out/after-upload-deletion-promise";
6+
7+
export default defineConfig({
8+
input: "src/basic.js",
9+
output: {
10+
file: `${outDir}/basic.js`,
11+
sourcemap: true,
12+
},
13+
plugins: [sentryRollupPlugin(getSentryConfig(outDir))],
14+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
import { existsSync } from "node:fs";
4+
import { join } from "node:path";
5+
6+
test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => {
7+
runBundler();
8+
9+
// Verify the JS file exists and works
10+
const output = runFileInNode("basic.js");
11+
expect(output).toBe("hello world\n");
12+
13+
// Verify the sourcemap was deleted (by the Promise)
14+
const sourcemapPath = join(outDir, "basic.js.map");
15+
expect(existsSync(sourcemapPath)).toBe(false);
16+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2+
import { defineConfig } from "rollup";
3+
import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js";
4+
5+
const outDir = "out/after-upload-deletion-promise";
6+
7+
export default defineConfig({
8+
input: "src/basic.js",
9+
output: {
10+
file: `${outDir}/basic.js`,
11+
sourcemap: true,
12+
},
13+
plugins: [sentryRollupPlugin(getSentryConfig(outDir))],
14+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
import { existsSync } from "node:fs";
4+
import { join } from "node:path";
5+
6+
test(import.meta.url, ({ runBundler, outDir, runFileInNode }) => {
7+
runBundler();
8+
9+
// Verify the JS file exists and works
10+
const output = runFileInNode("basic.js");
11+
expect(output).toBe("hello world\n");
12+
13+
// Verify the sourcemap was deleted (by the Promise)
14+
const sourcemapPath = join(outDir, "basic.js.map");
15+
expect(existsSync(sourcemapPath)).toBe(false);
16+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { sentryVitePlugin } from "@sentry/vite-plugin";
2+
import { defineConfig } from "vite";
3+
import { getSentryConfig } from "../configs/after-upload-deletion-promise.config.js";
4+
5+
const outDir = "out/after-upload-deletion-promise";
6+
7+
export default defineConfig({
8+
build: {
9+
minify: false,
10+
sourcemap: true,
11+
rollupOptions: {
12+
input: "src/basic.js",
13+
output: {
14+
dir: outDir,
15+
entryFileNames: "[name].js",
16+
},
17+
},
18+
},
19+
plugins: [sentryVitePlugin(getSentryConfig(outDir))],
20+
});

0 commit comments

Comments
 (0)