Skip to content

Commit 3d9a7f1

Browse files
committed
Skip the script-tag bundle test locally when the bundle isn't built
npm test on a fresh checkout failed because the test reads dist. CI still runs it and fails if the bundle is missing.
1 parent 83322da commit 3d9a7f1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/browser/test/global-bundle.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ import type * as ExceptionlessBrowser from "../src/index.js";
99

1010
type GlobalWindow = JSDOM["window"] & { exceptionless?: typeof ExceptionlessBrowser };
1111

12+
const distPath = resolve(dirname(fileURLToPath(import.meta.url)), "../dist");
13+
// These tests check the built bundles. Without a build they are skipped locally, but CI (which builds first) must run them.
14+
const bundlesMissing = !existsSync(resolve(distPath, "index.global.js")) && !process.env.CI;
15+
1216
function loadClassicScript(fileName: string): GlobalWindow {
13-
const filePath = resolve(dirname(fileURLToPath(import.meta.url)), "../dist", fileName);
17+
const filePath = resolve(distPath, fileName);
1418
if (!existsSync(filePath)) {
1519
throw new Error(`${filePath} does not exist. Run "npm run build --workspace=packages/browser" first.`);
1620
}
@@ -26,7 +30,7 @@ function loadClassicScript(fileName: string): GlobalWindow {
2630
return dom.window;
2731
}
2832

29-
describe("classic script bundle", () => {
33+
describe.skipIf(bundlesMissing)("classic script bundle", () => {
3034
test.each(["index.global.js", "index.global.min.js"])("%s exposes the SDK on window.exceptionless", async (fileName) => {
3135
const window = loadClassicScript(fileName);
3236

0 commit comments

Comments
 (0)