MCPcopy
hub / github.com/angular/angular / expectError

Function expectError

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…