From: Ardis Lu Date: Mon, 10 Feb 2025 04:12:26 +0000 (-0800) Subject: Assert example 1.6 logs to console X-Git-Tag: v0.1.0~60 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=87b7c2d483d8ce9d5e5d44cc267e3c232f0e60be;p=csvio Assert example 1.6 logs to console --- diff --git a/test/examples.test.js b/test/examples.test.js index b65ee33..a39e2f9 100644 --- a/test/examples.test.js +++ b/test/examples.test.js @@ -3,7 +3,7 @@ import { ok } from 'node:assert/strict'; import { mkdir, cp, opendir, readFile, rm } from 'node:fs/promises'; import { pathToFileURL } from 'node:url'; -import { createTempFolder } from './utils.js'; +import { createTempFolder, assertConsole } from './utils.js'; const dir = await createTempFolder(); const tempExamples = pathToFileURL(`${dir}/examples/`); // Trailing forward slash is REQUIRED for using this URL as a URL base later @@ -35,11 +35,22 @@ for await (const file of files) { suite('examples', { concurrency: true }, () => { after(async () => await rm(dir, { recursive: true, force: true })); for (const { name, code, output } of tests) { - test(name, { concurrency: true }, async () => { - const expected = await readFile(output); - await import(code); - const actual = await readFile(output); - ok(actual.equals(expected)); - }); + if (name === 'ex1_6') { + test(name, { concurrency: true }, async (t) => { + assertConsole(t, { log: 1 }); + const expected = await readFile(output); + await import(code); + const actual = await readFile(output); + ok(actual.equals(expected)); + }); + } + else { + test(name, { concurrency: true }, async () => { + const expected = await readFile(output); + await import(code); + const actual = await readFile(output); + ok(actual.equals(expected)); + }); + } } });