feat: basically the whole package

This commit is contained in:
2026-07-04 20:17:41 +02:00
parent 5b23824a56
commit b6c8c93430
9 changed files with 979 additions and 20 deletions
+83
View File
@@ -0,0 +1,83 @@
export interface Options {
/**
* Pattern matching files to include in parsing
*/
include: string[];
/**
* Pattern matching files to ignore when parsing
*/
exclude: string[];
/**
* Output directory, test files are emitted alongside their source files if
* not specified
*/
outDir: string | null;
/**
* File extension to emit test files with
* @default
* ".doc.test"
*/
fileExtension: string;
/**
* Name to use for tests. If not specified, then tests are named by what
* their jsdoc comments are documenting.
*/
testName: string | null;
/**
* Whether to replace any instance of `$PROJECT_ROOT` with a relative file path to
* the root of the project (e.g., for imports)
*/
templateRoot: boolean;
/**
* Lines to insert before the test file contents
*/
templateHeader: string[];
/**
* Lines to insert after the test file contents
*/
templateFooter: string[];
/**
* Test format to emit
* - `jest`/`vitest`: Generate `test(...)` and `describe(...)` calls with `expect(...)`
* - `assert`: Generate code to run `console.assert(...)`/`assert(...)`-style tests
*/
format: "jest" | "vitest" | "assert";
/**
* Whether or not tests only containing assertions should be emitted
*
* The assertion syntax is determined by {@link format}, e.g. `expect(...)`
* for Jest/Vitest.
*/
onlyGenerateTests: boolean;
/**
* Whether to require a markdown code block with an appropriate language to
* generate tests
*/
requireCodeBlock: boolean;
/**
* Whether to include a comment with a path to the test source file in each
* test
*/
includePath: boolean;
/**
* Whether or not to emit test regions for namespaces using the test harness
* (e.g. `describe()` regions in jest/vitest).
*/
emitRegions: boolean;
}
export const DEFAULT_OPTIONS: Required<Options> = {
include: [],
exclude: [],
outDir: null,
fileExtension: ".doc.test",
testName: null,
templateRoot: true,
templateHeader: [],
templateFooter: [],
format: "vitest",
onlyGenerateTests: false,
requireCodeBlock: false,
includePath: true,
emitRegions: true,
};