UNPKG

cli-testing-library

Version:

Simple and complete CLI testing utilities that encourage good testing practices.

34 lines (33 loc) 999 B
import { getDefaultNormalizer } from "../matches.js"; import { checkCliInstance, getMessage } from "./utils.js"; function toBeInTheConsole(instance) { if (instance !== null || !this.isNot) { checkCliInstance(instance, toBeInTheConsole, this); } const errormessage = instance ? 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 getMessage( this, this.utils.matcherHint( `${this.isNot ? ".not" : ""}.toBeInTheConsole`, "instance", "" ), `Expected ${to} find the instance in the console`, "", "Received", this.utils.printReceived(errormessage) ); } }; } export { toBeInTheConsole }; //# sourceMappingURL=to-be-in-the-console.js.map