test: added testing via a browser (puppeteer)
This commit is contained in:
32
test/util/print-code-output.ts
Normal file
32
test/util/print-code-output.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import process from "node:process";
|
||||
import chalk from "chalk";
|
||||
|
||||
import {TestOutput} from "./code-output.ts";
|
||||
|
||||
export const debugPrintOutput = async (header: string, files: TestOutput[]) => {
|
||||
const out = [];
|
||||
|
||||
const headFn = chalk.bgCyan;
|
||||
const headPadding = header.split('').map(x=>'#').join('');
|
||||
out.push(...[
|
||||
headFn(`##${headPadding}##`),
|
||||
headFn(`# ${header} #`),
|
||||
headFn(`##${headPadding}##`),
|
||||
]);
|
||||
|
||||
const fileHeadFn = chalk.blue;
|
||||
const fileContentFn = chalk.blackBright;
|
||||
out.push(...(files.map(file=>{
|
||||
return [
|
||||
fileHeadFn(`${file.fileName}:`),
|
||||
fileContentFn(`${file.code??file.source}`),
|
||||
'',
|
||||
]
|
||||
}).flat()));
|
||||
|
||||
out.push(...[
|
||||
headFn(`##${headPadding}##`),
|
||||
]);
|
||||
|
||||
process.env.DEBUG? console.log(out.join('\n')) : null;
|
||||
};
|
||||
Reference in New Issue
Block a user