cli-testing-library
Version:
Simple and complete CLI testing utilities that encourage good testing practices.
1 lines • 1.95 kB
Source Map (JSON)
{"version":3,"file":"to-be-in-the-console.cjs","sources":["../../../src/matchers/to-be-in-the-console.ts"],"sourcesContent":["import { getDefaultNormalizer } from \"../matches\";\nimport { checkCliInstance, getMessage } from \"./utils\";\nimport type { TestInstance } from \"../types\";\n\nexport function toBeInTheConsole(this: any, instance: TestInstance) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (instance !== null || !this.isNot) {\n checkCliInstance(instance, toBeInTheConsole, this);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const errormessage = instance\n ? getDefaultNormalizer()(\n instance.stdoutArr.map((obj) => obj.contents).join(\"\\n\"),\n )\n : null;\n\n return {\n // Does not change based on `.not`, and as a result, we must confirm if it _actually_ is there\n pass: !!instance,\n message: () => {\n const to = this.isNot ? \"not to\" : \"to\";\n return getMessage(\n this,\n this.utils.matcherHint(\n `${this.isNot ? \".not\" : \"\"}.toBeInTheConsole`,\n \"instance\",\n \"\",\n ),\n `Expected ${to} find the instance in the console`,\n \"\",\n \"Received\",\n this.utils.printReceived(errormessage),\n );\n },\n };\n}\n"],"names":["checkCliInstance","getDefaultNormalizer","getMessage"],"mappings":";;;;AAIO,SAAS,iBAA4B,UAAwB;AAElE,MAAI,aAAa,QAAQ,CAAC,KAAK,OAAO;AACnBA,2BAAA,UAAU,kBAAkB,IAAI;AAAA,EAAA;AAI7C,QAAA,eAAe,WACjBC,6BAAqB;AAAA,IACnB,SAAS,UAAU,IAAI,CAAC,QAAQ,IAAI,QAAQ,EAAE,KAAK,IAAI;AAAA,EAAA,IAEzD;AAEG,SAAA;AAAA;AAAA,IAEL,MAAM,CAAC,CAAC;AAAA,IACR,SAAS,MAAM;AACP,YAAA,KAAK,KAAK,QAAQ,WAAW;AAC5B,aAAAC,MAAA;AAAA,QACL;AAAA,QACA,KAAK,MAAM;AAAA,UACT,GAAG,KAAK,QAAQ,SAAS,EAAE;AAAA,UAC3B;AAAA,UACA;AAAA,QACF;AAAA,QACA,YAAY,EAAE;AAAA,QACd;AAAA,QACA;AAAA,QACA,KAAK,MAAM,cAAc,YAAY;AAAA,MACvC;AAAA,IAAA;AAAA,EAEJ;AACF;;"}