From 2d62ca4267605e98c4e4c144181329c2529c2459 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 21 Jun 2026 01:36:01 -0600 Subject: [PATCH 1/3] fix: add renderOk option --- src/run-tests.ts | 15 ++++++++------- src/types.ts | 3 ++- test/run-tests.test.ts | 24 +++++++++++++++++++++++- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/run-tests.ts b/src/run-tests.ts index ee9e084..c5f9734 100644 --- a/src/run-tests.ts +++ b/src/run-tests.ts @@ -64,18 +64,19 @@ export async function runTests({ const before = process.hrtime(); const parsed = await parse(test.markdown, options, addExtension); const elapsed = process.hrtime(before); - const pass = isEqual(parsed, test.html); - if (test.shouldFail) { + if (options.renderOk) { + // doesn't check the output against the html but just that it doesn't throw an error + } else if (options.renderExact) { + assert.strictEqual(test.html ?? '', parsed); + } else if (test.shouldFail) { assert.ok( - !pass, + !isEqual(parsed, test.html ?? ''), `${test.markdown}\n------\n\nExpected: Should Fail`, ); - } else if (options.renderExact) { - assert.strictEqual(test.html, parsed); } else { - const testDiff = diff(parsed, test.html); + const testDiff = diff(parsed, test.html ?? ''); assert.ok( - pass, + isEqual(parsed, test.html ?? ''), `Expected: ${testDiff.expected}\n Actual: ${testDiff.actual}`, ); } diff --git a/src/types.ts b/src/types.ts index 7e2947f..8af290e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,9 +3,10 @@ import { MarkedExtension } from "marked"; export interface Spec { section: string; markdown: string; - html: string; + html?: string; options?: MarkedExtension & { renderExact?: boolean; + renderOk?: boolean; }; only?: boolean; skip?: boolean; diff --git a/test/run-tests.test.ts b/test/run-tests.test.ts index ebde81d..a251fd0 100644 --- a/test/run-tests.test.ts +++ b/test/run-tests.test.ts @@ -1,8 +1,30 @@ -import { runAllMarkedSpecTests } from "../src/index.js"; +import { runAllMarkedSpecTests, runTests } from "../src/index.js"; import test from "node:test"; +import assert from "node:assert"; test("run-tests", async (t) => { await t.test("runAllMarkedSpecTests", async () => { await runAllMarkedSpecTests(); }); + + await t.test("renderOk option", async () => { + // This test should pass because renderOk is true even though html does not match the actual parsed output. + await runTests({ + tests: { + "Render OK Section": { + total: 1, + pass: 1, + specs: [ + { + section: "Render OK Section", + markdown: "hello", + options: { + renderOk: true, + }, + }, + ], + }, + }, + }); + }); }); From eba571be460875da55a5939dff18efdc60f30bef Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 21 Jun 2026 11:07:41 -0600 Subject: [PATCH 2/3] format --- src/run-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/run-tests.ts b/src/run-tests.ts index c5f9734..c0cc03b 100644 --- a/src/run-tests.ts +++ b/src/run-tests.ts @@ -67,16 +67,16 @@ export async function runTests({ if (options.renderOk) { // doesn't check the output against the html but just that it doesn't throw an error } else if (options.renderExact) { - assert.strictEqual(test.html ?? '', parsed); + assert.strictEqual(test.html ?? "", parsed); } else if (test.shouldFail) { assert.ok( - !isEqual(parsed, test.html ?? ''), + !isEqual(parsed, test.html ?? ""), `${test.markdown}\n------\n\nExpected: Should Fail`, ); } else { - const testDiff = diff(parsed, test.html ?? ''); + const testDiff = diff(parsed, test.html ?? ""); assert.ok( - isEqual(parsed, test.html ?? ''), + isEqual(parsed, test.html ?? ""), `Expected: ${testDiff.expected}\n Actual: ${testDiff.actual}`, ); } From bcf21561543341e840ecad5e7c254e375bf8a1ee Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sun, 21 Jun 2026 11:11:57 -0600 Subject: [PATCH 3/3] assert ok --- src/run-tests.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/run-tests.ts b/src/run-tests.ts index c0cc03b..5ba9a7a 100644 --- a/src/run-tests.ts +++ b/src/run-tests.ts @@ -65,7 +65,10 @@ export async function runTests({ const parsed = await parse(test.markdown, options, addExtension); const elapsed = process.hrtime(before); if (options.renderOk) { - // doesn't check the output against the html but just that it doesn't throw an error + assert.ok( + parsed, + `${test.markdown}\n------\n\nExpected: To Render Anything`, + ); } else if (options.renderExact) { assert.strictEqual(test.html ?? "", parsed); } else if (test.shouldFail) {