From cc848c9bbc14f78414752f863cd5656c434a5fc1 Mon Sep 17 00:00:00 2001 From: Nixinova Date: Sun, 15 Sep 2024 18:30:15 +1200 Subject: [PATCH] Fix unit test runner --- src/index.ts | 1 - test/unit.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 715a231..12528fa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -422,7 +422,6 @@ async function analyse(rawPaths?: string | string[], opts: T.Options = {}): Prom // Calculate lines of code const loc = { total: 0, content: 0, code: 0 }; if (opts.calculateLines) { - // TODO: catch error? const fileContent = (manualFileContent[files.indexOf(file)] ?? fs.readFileSync(file).toString()) ?? ''; const allLines = fileContent.split(/\r?\n/gm); loc.total = allLines.length; diff --git a/test/unit.js b/test/unit.js index 00fdb61..0264e1b 100644 --- a/test/unit.js +++ b/test/unit.js @@ -22,7 +22,7 @@ async function test([filename, fileContent = ''], [type, testVal]) { } else { errors++; - console.error(`- #${i} failed: '${filename}' is ${testContent} instead of ${testVal}`); + console.error(`! #${i} failed: '${filename}' is ${testContent} instead of ${testVal}`); } } @@ -80,8 +80,8 @@ async function unitTest() { await test(['unknown'], ['files', null]); if (errors) { - const message = `\nExited with ${errors} errors.\n`; - throw console.error(message), message; + console.error(`\n! Exited with ${errors} errors.\n`); + return; } else console.info('All unit tests passed'); }