Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/smoke/build-ts-extension/build-ts-extension.test.ts
6570 views
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
);
50
51