From 157d69070465bd976b9b1ae919d22ae47b6fc0ae Mon Sep 17 00:00:00 2001 From: JoostK Date: Thu, 26 Nov 2020 23:38:08 +0100 Subject: [PATCH] test(compiler-cli): expand logging when extra compliance check fails (#39863) Previously this would have just printed that `false` was not equal to `true`, which, although true, is not very helpful. This commit adds details about which special check failed together with the generated code, for easier debugging. PR Close #39863 --- .../test/compliance/test_helpers/check_expectations.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts b/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts index a39d1d9976..7fc6512675 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts @@ -79,6 +79,10 @@ function runExtraChecks( `Unknown extra-check function: "${fnName}" in ${testPath}.\n` + `Possible choices are: ${Object.keys(EXTRA_CHECK_FUNCTIONS).map(f => `\n - ${f}`)}.`); } - expect(fn(generated, ...args)).toBe(true); + if (!fn(generated, ...args)) { + throw new Error( + `Extra check ${fnName}(${args.map(arg => JSON.stringify(arg)).join(',')}) in ${ + testPath} failed for generated code:\n\n${generated}`); + } } }