Skip to content

Commit c23c9d3

Browse files
carderneTrigger.dev RepoOps
authored andcommitted
fix(core): keep schema compatibility test failure output readable
Keep schema compatibility test failures readable by importing esbuild bundles from temporary `.mjs` files instead of base64 data URLs. Both test cases retain their assertions and original error details, and remove the temporary directory in `finally`. Mono-RevId: a692eadb7923de0ccb4d09c4b6d11953d2837b82
1 parent 8bb48c9 commit c23c9d3

1 file changed

Lines changed: 30 additions & 18 deletions

File tree

‎packages/core/src/v3/schemas/schemaCompositionCompatibility.test.ts‎

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { build } from "esbuild";
2+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
23
import { createRequire } from "node:module";
3-
import { dirname, resolve } from "node:path";
4-
import { fileURLToPath } from "node:url";
4+
import { tmpdir } from "node:os";
5+
import { dirname, join, resolve } from "node:path";
6+
import { fileURLToPath, pathToFileURL } from "node:url";
57
import { describe, expect, it } from "vitest";
68

79
const require = createRequire(import.meta.url);
@@ -80,16 +82,21 @@ describe("schema composition compatibility", () => {
8082
],
8183
});
8284

83-
const bundledModule = await import(
84-
`data:text/javascript;base64,${Buffer.from(result.outputFiles[0]!.text).toString("base64")}`
85-
);
85+
const tempDir = await mkdtemp(join(tmpdir(), "schema-composition-"));
86+
try {
87+
const bundlePath = join(tempDir, "bundle.mjs");
88+
await writeFile(bundlePath, result.outputFiles[0]!.text);
89+
const bundledModule = await import(pathToFileURL(bundlePath).href);
8690

87-
expect(bundledModule.parsed).toMatchObject({
88-
retry: { resetFormat: "unix_timestamp" },
89-
schedule: { window: "10%" },
90-
metadata: { id: "my-webhook" },
91-
resource: { id: "my-webhook" },
92-
});
91+
expect(bundledModule.parsed).toMatchObject({
92+
retry: { resetFormat: "unix_timestamp" },
93+
schedule: { window: "10%" },
94+
metadata: { id: "my-webhook" },
95+
resource: { id: "my-webhook" },
96+
});
97+
} finally {
98+
await rm(tempDir, { recursive: true, force: true });
99+
}
93100
});
94101

95102
it.each([
@@ -161,13 +168,18 @@ describe("schema composition compatibility", () => {
161168
],
162169
});
163170

164-
const bundledModule = await import(
165-
`data:text/javascript;base64,${Buffer.from(result.outputFiles[0]!.text).toString("base64")}`
166-
);
171+
const tempDir = await mkdtemp(join(tmpdir(), "schema-composition-"));
172+
try {
173+
const bundlePath = join(tempDir, "bundle.mjs");
174+
await writeFile(bundlePath, result.outputFiles[0]!.text);
175+
const bundledModule = await import(pathToFileURL(bundlePath).href);
167176

168-
expect(bundledModule.parsed).toMatchObject({
169-
dequeued: { run: { id: "run_1" }, snapshotRoute: { residency: "postgres" } },
170-
attemptStart: { isWarmStart: true, snapshotRoute: { residency: "postgres" } },
171-
});
177+
expect(bundledModule.parsed).toMatchObject({
178+
dequeued: { run: { id: "run_1" }, snapshotRoute: { residency: "postgres" } },
179+
attemptStart: { isWarmStart: true, snapshotRoute: { residency: "postgres" } },
180+
});
181+
} finally {
182+
await rm(tempDir, { recursive: true, force: true });
183+
}
172184
});
173185
});

0 commit comments

Comments
 (0)