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

Function expectError

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

Source from the content-addressed store, hash-verified

1827}
1828
1829function expectError(ast: {errors: ParseError[]}, message: string, errorCount?: number) {
1830 if (errorCount != null) {
1831 expect(ast.errors.length).toBe(errorCount);
1832 } else {
1833 expect(ast.errors.length).toBeGreaterThan(0);
1834 }
1835
1836 for (const error of ast.errors) {
1837 if (error.msg.indexOf(message) >= 0) {
1838 return;
1839 }
1840 }
1841 const errMsgs = ast.errors.map((err) => err.msg).join('\n');
1842 throw Error(
1843 `Expected an error containing "${message}" to be reported, but got the errors:\n` + errMsgs,
1844 );
1845}
1846
1847function expectActionError(text: string, message: string, errorCount?: number) {
1848 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