MCPcopy Create free account
hub / github.com/angular/angular / expectError

Function expectError

packages/compiler/test/expression_parser/parser_spec.ts:2078–2094  ·  view source on GitHub ↗
(ast: {errors: ParseError[]}, message: string, errorCount?: number)

Source from the content-addressed store, hash-verified

2076}
2077
2078function expectError(ast: {errors: ParseError[]}, message: string, errorCount?: number) {
2079 if (errorCount != null) {
2080 expect(ast.errors.length).toBe(errorCount);
2081 } else {
2082 expect(ast.errors.length).toBeGreaterThan(0);
2083 }
2084
2085 for (const error of ast.errors) {
2086 if (error.msg.indexOf(message) >= 0) {
2087 return;
2088 }
2089 }
2090 const errMsgs = ast.errors.map((err) => err.msg).join('\n');
2091 throw Error(
2092 `Expected an error containing "${message}" to be reported, but got the errors:\n` + errMsgs,
2093 );
2094}
2095
2096function expectActionError(text: string, message: string, errorCount?: number) {
2097 expectError(validate(parseAction(text)), message, errorCount);

Callers 3

parser_spec.tsFile · 0.85
expectActionErrorFunction · 0.85
expectBindingErrorFunction · 0.85

Calls 4

ErrorInterface · 0.85
indexOfMethod · 0.80
mapMethod · 0.80
joinMethod · 0.65

Tested by

no test coverage detected