Skip to content

Commit

Permalink
test(esbuild): Add test to check for compatibility with inject option
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Oct 5, 2023
1 parent 40f9184 commit bef26ba
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import childProcess from "child_process";
import path from "path";

const outputBundlePath = path.join(__dirname, "out", "index.js");

test("check functionality", () => {
const processOutput = childProcess.execSync(`node ${outputBundlePath}`, { encoding: "utf-8" });
expect(processOutput).toMatch(/injected fallback/);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore just a test file
const FOO = process.env.FOO ? "injected value" : "injected fallback";

// eslint-disable-next-line no-console
console.log(FOO);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const process = { cwd: () => "", env: {} };
// eslint-disable-next-line no-undef
export const global = globalThis;
20 changes: 20 additions & 0 deletions packages/integration-tests/fixtures/esbuild-inject-compat/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { sentryEsbuildPlugin } from "@sentry/esbuild-plugin";
import esbuild from "esbuild019";
import path from "path";

esbuild
.build({
bundle: true,
entryPoints: [path.resolve(__dirname, "./input/index.ts")],
outdir: path.resolve(__dirname, "./out"),
inject: [path.resolve(__dirname, "./input/inject.ts")],
plugins: [
sentryEsbuildPlugin({
telemetry: false,
}),
],
minify: false,
})
.catch((e) => {
throw e;
});
1 change: 1 addition & 0 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@types/jest": "^28.1.3",
"@types/webpack4": "npm:@types/webpack@^4",
"esbuild": "0.14.49",
"esbuild019": "npm:esbuild@^0.19.4",
"eslint": "^8.18.0",
"jest": "^28.1.3",
"rollup": "3.2.0",
Expand Down

0 comments on commit bef26ba

Please sign in to comment.