| paths |
|
|---|
TypeScript-based tests using Deno. Smoke tests render documents; unit tests verify isolated functionality.
# Linux/macOS
./run-tests.sh smoke/render/render.test.ts # Specific smoke test
./run-tests.sh unit/path.test.ts # Specific unit test
./run-tests.sh smoke/extensions/ # Directory
# Windows
.\run-tests.ps1 smoke/render/render.test.ts| File | Purpose |
|---|---|
tests/test.ts |
testQuartoCmd(), testRender(), unitTest() |
tests/verify.ts |
Verification functions (noErrors, fileExists, etc.) |
tests/utils.ts |
docs(), outputForInput(), path utilities |
Render documents and verify output:
import { testRender } from "./render.ts";
import { noErrorsOrWarnings } from "../../verify.ts";
import { docs } from "../../utils.ts";
testRender(
"test.qmd",
"html",
false, // Keep output?
[noErrorsOrWarnings],
{ cwd: () => docs("my-feature/") }
);With setup/teardown:
testRender("test.qmd", "html", false, [noErrorsOrWarnings], {
cwd: () => inputDir,
setup: async () => { /* Create temp files */ },
teardown: async () => { /* Cleanup */ },
});Test isolated functionality:
import { unitTest } from "../test.ts";
import { assert, assertEquals } from "testing/asserts";
// deno-lint-ignore require-await
unitTest("feature - description", async () => {
const result = myFunction(input);
assertEquals(result, expected);
});Assertions from testing/asserts: assert, assertEquals, assertThrows, assertRejects
Temp files:
const workingDir = Deno.makeTempDirSync({ prefix: "quarto-test" });
// Use workingDir, clean up in teardownFixtures:
const fixtureDir = docs("my-fixture"); // → tests/docs/my-fixture/tests/smoke/<feature>/- Smoke tests by featuretests/unit/<feature>/- Unit tests by featuretests/docs/<feature>/- Test fixtures
Details: llm-docs/testing-patterns.md for comprehensive patterns and examples.
Constructing MappedString values:
import { asMappedString } from "../../../src/core/lib/mapped-text.ts";
// Use asMappedString("") instead of casting or constructing MappedString manually
const markdown = asMappedString("");
const markdownWithContent = asMappedString("# Title\nSome content");Mock ProjectContext:
import { createMockProjectContext } from "./utils.ts"; // tests/unit/project/utils.ts
const project = createMockProjectContext(); // Creates temp dir + FileInformationCacheMap