diff --git a/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts b/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts index 169c038db9..5eccb24c44 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts @@ -22,3 +22,11 @@ export function checkErrors( } } } + +export function checkNoUnexpectedErrors(testPath: string, actualErrors: string[]): void { + if (actualErrors.length > 0) { + throw new Error( + `Unexpected errors occurred for test case at "${testPath}"\n` + + `Errors: ${inspect(actualErrors)}.`); + } +} diff --git a/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts b/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts index 59b48d3506..19501f6c7c 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts @@ -9,7 +9,7 @@ import {FileSystem} from '../../../src/ngtsc/file_system'; import {checkExpectations} from '../test_helpers/check_expectations'; import {CompileResult, initMockTestFileSystem} from '../test_helpers/compile_test'; import {ComplianceTest, getAllComplianceTests} from '../test_helpers/get_compliance_tests'; -import {checkErrors} from './check_errors'; +import {checkErrors, checkNoUnexpectedErrors} from './check_errors'; /** * Set up jasmine specs for each of the compliance tests. @@ -46,6 +46,7 @@ export function runTests( test.relativePath, expectation.failureMessage, expectation.expectedErrors, errors); } else { + checkNoUnexpectedErrors(test.relativePath, errors); checkExpectations( fs, test.relativePath, expectation.failureMessage, expectation.files, expectation.extraChecks);