Skip to content

Commit 8b1af04

Browse files
claude: Add smoke test for build-ts-extension
Add test that verifies build-ts-extension correctly bundles TypeScript engine extensions. Test validates that imports from the import map (like @std/path) are properly bundled into the output JavaScript file. Remove deno.json from test to verify auto-detection of entry point from src/ directory works correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 26dd252 commit 8b1af04

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { noErrorsOrWarnings } from "../../verify.ts";
2+
import { testQuartoCmd, Verify } from "../../test.ts";
3+
import { assert } from "testing/asserts";
4+
import { existsSync } from "../../../src/deno_ral/fs.ts";
5+
6+
const verifyBundleCreated: Verify = {
7+
name: "Verify bundled JS file was created",
8+
verify: async () => {
9+
const bundlePath = "_extensions/test-engine/test-engine.js";
10+
assert(
11+
existsSync(bundlePath),
12+
`Expected bundled file not found: ${bundlePath}`,
13+
);
14+
},
15+
};
16+
17+
const verifyImportBundled: Verify = {
18+
name: "Verify import from import map was bundled",
19+
verify: async () => {
20+
const bundlePath = "_extensions/test-engine/test-engine.js";
21+
const content = Deno.readTextFileSync(bundlePath);
22+
23+
// Check that the file is substantial (contains bundled dependencies, not just source)
24+
assert(
25+
content.length > 1000,
26+
`Bundle file seems too small (${content.length} bytes), dependencies may not be bundled`,
27+
);
28+
29+
// Check that extname function declaration is in the bundle (lightweight check)
30+
assert(
31+
content.includes("function extname"),
32+
"Bundle does not contain 'function extname' - import may not have been bundled",
33+
);
34+
},
35+
};
36+
37+
testQuartoCmd(
38+
"call",
39+
["build-ts-extension"],
40+
[
41+
noErrorsOrWarnings,
42+
verifyBundleCreated,
43+
verifyImportBundled,
44+
],
45+
{
46+
cwd: () => "smoke/build-ts-extension",
47+
},
48+
"build-ts-extension creates bundled engine",
49+
);

tests/smoke/build-ts-extension/deno.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/smoke/build-ts-extension/src/test-engine.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
PostProcessOptions,
1313
PartitionedMarkdown,
1414
} from "@quarto/types";
15+
import { extname } from "path";
1516

1617
let quarto: QuartoAPI;
1718

@@ -73,6 +74,8 @@ const testEngineDiscovery: ExecutionEngineDiscovery = {
7374

7475
execute: async (options: ExecuteOptions): Promise<ExecuteResult> => {
7576
// Simple passthrough - no actual execution
77+
// Use extname to ensure it gets bundled
78+
const _ext = extname(options.target.input);
7679
return {
7780
markdown: options.target.markdown.value,
7881
supporting: [],

0 commit comments

Comments
 (0)