MCPcopy Index your code
hub / github.com/angular/angular-cli / expectToFail

Function expectToFail

tests/e2e/utils/utils.ts:6–19  ·  view source on GitHub ↗
(fn: () => Promise<any>, errorMessage?: string)

Source from the content-addressed store, hash-verified

4import path from 'node:path';
5
6export function expectToFail(fn: () => Promise<any>, errorMessage?: string): Promise<Error> {
7 return fn().then(
8 () => {
9 const functionSource = fn.name || (<any>fn).source || fn.toString();
10 const errorDetails = errorMessage ? `\n\tDetails:\n\t${errorMessage}` : '';
11 throw new Error(
12 `Function ${functionSource} was expected to fail, but succeeded.${errorDetails}`,
13 );
14 },
15 (err) => {
16 return err instanceof Error ? err : new Error(err);
17 },
18 );
19}
20
21export async function mktempd(prefix: string, tempRoot?: string): Promise<string> {
22 return realpath(await mkdtemp(path.join(tempRoot ?? tmpdir(), prefix)));

Calls 2

fnFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected