Skip to content

Instantly share code, notes, and snippets.

@ryanluker
Last active May 23, 2022 18:24
Show Gist options
  • Save ryanluker/bba7808e3b1bbd5fe33da8936731ec73 to your computer and use it in GitHub Desktop.
Save ryanluker/bba7808e3b1bbd5fe33da8936731ec73 to your computer and use it in GitHub Desktop.
import * as assert from "assert";
import * as fs from "fs";
// Original functions
const readFile = fs.readFile;
teardown(function() {
(fs as any).readFile = readFile;
});
test("#load: Should reject when readFile returns an error @unit", function(done) {
const readFile = function(path: string, cb) {
assert.equal(path, "pathtofile");
const error: NodeJS.ErrnoException = new Error("could not read from fs");
return cb(error, Buffer.from(""));
};
(fs as any).readFile = readFile;
const coverage = new Coverage(
fakeConfig,
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment