Path: blob/main/tests/smoke/build-ts-extension/build-ts-extension.test.ts
6570 views
import { noErrorsOrWarnings } from "../../verify.ts";1import { testQuartoCmd, Verify } from "../../test.ts";2import { assert } from "testing/asserts";3import { existsSync } from "../../../src/deno_ral/fs.ts";45const verifyBundleCreated: Verify = {6name: "Verify bundled JS file was created",7verify: async () => {8const bundlePath = "_extensions/test-engine/test-engine.js";9assert(10existsSync(bundlePath),11`Expected bundled file not found: ${bundlePath}`,12);13},14};1516const verifyImportBundled: Verify = {17name: "Verify import from import map was bundled",18verify: async () => {19const bundlePath = "_extensions/test-engine/test-engine.js";20const content = Deno.readTextFileSync(bundlePath);2122// Check that the file is substantial (contains bundled dependencies, not just source)23assert(24content.length > 1000,25`Bundle file seems too small (${content.length} bytes), dependencies may not be bundled`,26);2728// Check that extname function declaration is in the bundle (lightweight check)29assert(30content.includes("function extname"),31"Bundle does not contain 'function extname' - import may not have been bundled",32);33},34};3536testQuartoCmd(37"call",38["build-ts-extension"],39[40noErrorsOrWarnings,41verifyBundleCreated,42verifyImportBundled,43],44{45cwd: () => "smoke/build-ts-extension",46},47"build-ts-extension creates bundled engine",48);495051