test(compiler-cli): improve error message if a unit test is bad (#38959)

The message now also reports the name of the predicate function
that failed.

PR Close #38959
This commit is contained in:
Pete Bacon Darwin 2020-09-27 10:42:28 +01:00 committed by atscott
parent 118f37b174
commit cee393d0da
1 changed files with 2 additions and 1 deletions

View File

@ -60,7 +60,8 @@ export function getDeclaration<T extends ts.Declaration>(
throw new Error(`No such symbol: ${name} in ${fileName}`);
}
if (!assert(chosenDecl)) {
throw new Error(`Symbol ${name} from ${fileName} is a ${ts.SyntaxKind[chosenDecl.kind]}`);
throw new Error(`Symbol ${name} from ${fileName} is a ${
ts.SyntaxKind[chosenDecl.kind]}. Expected it to pass predicate "${assert.name}()".`);
}
return chosenDecl;
}