cli-testing-library
Version:
Simple and complete CLI testing utilities that encourage good testing practices.
34 lines (33 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const matches = require("../matches.cjs");
const utils = require("./utils.cjs");
function toBeInTheConsole(instance) {
if (instance !== null || !this.isNot) {
utils.checkCliInstance(instance, toBeInTheConsole, this);
}
const errormessage = instance ? matches.getDefaultNormalizer()(
instance.stdoutArr.map((obj) => obj.contents).join("\n")
) : null;
return {
// Does not change based on `.not`, and as a result, we must confirm if it _actually_ is there
pass: !!instance,
message: () => {
const to = this.isNot ? "not to" : "to";
return utils.getMessage(
this,
this.utils.matcherHint(
`${this.isNot ? ".not" : ""}.toBeInTheConsole`,
"instance",
""
),
`Expected ${to} find the instance in the console`,
"",
"Received",
this.utils.printReceived(errormessage)
);
}
};
}
exports.toBeInTheConsole = toBeInTheConsole;
//# sourceMappingURL=to-be-in-the-console.cjs.map