Skip to content

Commit

Permalink
fix(test): makes c8 stop processing again when coverage is too low
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Nov 12, 2023
1 parent ae9b688 commit 41b20c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
7 changes: 4 additions & 3 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"statements": 99.9,
"branches": 99.7,
"checkCoverage": true,
"statements": 99.89,
"branches": 98.72,
"functions": 100,
"lines": 99.9,
"lines": 99.89,
"exclude": [
"bin",
"configs",
Expand Down
22 changes: 0 additions & 22 deletions src/cache/helpers.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check
import { createHash } from "node:crypto";
import { readFileSync } from "node:fs";
import { readFile } from "node:fs/promises";
import { extname } from "node:path";
import memoize from "lodash/memoize.js";
// @ts-expect-error ts(2307) - the ts compiler is not privy to the existence of #imports in package.json
Expand All @@ -15,27 +14,6 @@ function hash(pString) {
return createHash("sha1").update(pString).digest("base64");
}

/**
* @param {string} pFileName
* @returns {Promise<string>}
*/
async function _getFileHash(pFileName) {
try {
return hash(await readFile(pFileName, "utf8"));
} catch (pError) {
return "file not found";
}
}

export const getFileHash = memoize(_getFileHash);

export async function addCheckSumToChange(pChange) {
return {
...pChange,
checksum: await getFileHash(pChange.name),
};
}

/**
* @param {string} pFileName
* @returns {string}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
formatMemory,
formatPerfLine,
} from "#cli/listeners/performance-log/format-helpers.mjs";
import { DEBUG } from "#utl/bus.mjs";

/*
* as the formatHelpers use the Intl API, it's necessary to set the locale
Expand Down Expand Up @@ -80,7 +81,7 @@ describe("[U] cli/listeners/performance-log/format-helpers - formatMemory", () =
});

it("converts to kB, left pads & adds the unit at the end (not a number)", () => {
equal(formatMemory("not a number"), " NaNkB ");
equal(formatMemory("not a number", DEBUG), " NaNkB ");
});
});

Expand Down

0 comments on commit 41b20c6

Please sign in to comment.