Test utilities for marked and marked extensions.
This is versioned as the version of marked that it includes tests for with the prerelease version being an integer that gets incremented when we release a new fix or feature without updating the marked version.
We recommend to pin to a single version instead of using a range since any update may contain breaking changes.
Example
// package.json
"dependencies": {
"@markedjs/testutils": "9.1.0-0"
}
Get all marked Tests
Get Tests from a directory or file.
dirs
can be a string or an array of strings.
The return type is the same as the input a Tests object or an array of Tests objects.
Check if html will display the same.
Get the first difference between actual and expected HTML. Returns an object with the characters around the index of the first difference in the expected and actual strings.
Display a table in stdout that lists the sections and what percentage of the tests are not marked shouldFail.
Run spec tests
Run all marked specs with an added extension and optionally output completion table.
interface Tests {
total: number;
pass: number;
specs: Spec[];
}
interface Spec {
section?: string;
markdown: string;
html: string;
example?: number;
options?: MarkedOptions;
only?: boolean;
skip?: boolean;
shouldFail?: boolean;
}
type defaultMarkedOptions = MarkedOptions;
function parse(
markdown: string,
options: MarkedOptions,
addExtension: addExtension,
): string;
function addExtension(marked: Marked): void;
function isEqual(actual: string, expected: string): boolean;
function diff(
actual: string,
expected: string,
padding: number,
): { expected: string; actual: string };