UNPKG

console-fail-test

Version:

Gently fails test runs if the console was used during them. 📢

1 lines • 1.64 kB
{"version":3,"sources":["../../../src/environments/jasmine.ts"],"sourcesContent":["import { TestFrameworkSelector } from \"./testEnvironmentTypes.js\";\n\ndeclare const afterEach: (callback: () => void) => void;\ndeclare const beforeEach: (callback: () => void) => void;\ndeclare const jasmine: {\n\tSpec: unknown;\n};\n\nconst isJasmine = () => {\n\treturn (\n\t\ttypeof afterEach !== \"undefined\" &&\n\t\ttypeof beforeEach !== \"undefined\" &&\n\t\ttypeof jasmine !== \"undefined\" &&\n\t\ttypeof jasmine.Spec !== \"undefined\"\n\t);\n};\n\nexport const selectJasmineEnvironment: TestFrameworkSelector = () => {\n\tif (!isJasmine()) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tafterEach: (callback) => {\n\t\t\tafterEach(() => {\n\t\t\t\tcallback({\n\t\t\t\t\treportComplaint({ error }) {\n\t\t\t\t\t\t// Jasmine prints the error stack along with its message, resulting in a duplicate message\n\t\t\t\t\t\terror.stack = error.stack!.substring(error.message.length);\n\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t});\n\t\t},\n\t\tbeforeEach: (callback) => {\n\t\t\tbeforeEach(callback);\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,MAAM,YAAY,MAAM;AACvB,SACC,OAAO,cAAc,eACrB,OAAO,eAAe,eACtB,OAAO,YAAY,eACnB,OAAO,QAAQ,SAAS;AAE1B;AAEO,MAAM,2BAAkD,MAAM;AACpE,MAAI,CAAC,UAAU,GAAG;AACjB,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,WAAW,CAAC,aAAa;AACxB,gBAAU,MAAM;AACf,iBAAS;AAAA,UACR,gBAAgB,EAAE,MAAM,GAAG;AAE1B,kBAAM,QAAQ,MAAM,MAAO,UAAU,MAAM,QAAQ,MAAM;AAEzD,kBAAM;AAAA,UACP;AAAA,QACD,CAAC;AAAA,MACF,CAAC;AAAA,IACF;AAAA,IACA,YAAY,CAAC,aAAa;AACzB,iBAAW,QAAQ;AAAA,IACpB;AAAA,EACD;AACD;","names":[]}