MCPcopy Create free account
hub / github.com/angular/components / expectRejection

Function expectRejection

src/cdk/testing/tests/cross-environment-tests.ts:731–745  ·  view source on GitHub ↗
(fn: () => Promise<unknown>, expectedError: string | RegExp)

Source from the content-addressed store, hash-verified

729}
730
731async function expectRejection(fn: () => Promise<unknown>, expectedError: string | RegExp) {
732 let error = '<blank>';
733
734 try {
735 await fn();
736 } catch (e) {
737 error = (e as Error).message;
738 }
739
740 if (typeof expectedError === 'string') {
741 expect(error).toContain(expectedError);
742 } else {
743 expect(error).toMatch(expectedError);
744 }
745}

Callers 1

crossEnvironmentSpecsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected