MCPcopy
hub / github.com/graphql/graphql-js / toRejectWith

Function toRejectWith

src/__testUtils__/expectPromise.ts:40–61  ·  view source on GitHub ↗
(message: string)

Source from the content-addressed store, hash-verified

38 return caughtError;
39 },
40 async toRejectWith(message: string): Promise<Error> {
41 let caughtError: unknown;
42 let resolved;
43 let rejected = false;
44 try {
45 resolved = await maybePromise;
46 } catch (error) {
47 rejected = true;
48 caughtError = error;
49 }
50
51 assert(
52 rejected,
53 `Promise should have rejected with message '${message}', but resolved as '${inspect(
54 resolved,
55 )}'`,
56 );
57
58 expect(caughtError).to.be.an.instanceOf(Error);
59 expect(caughtError).to.have.property('message', message);
60 return caughtError as Error;
61 },
62 };
63}

Callers

nothing calls this directly

Calls 1

inspectFunction · 0.90

Tested by

no test coverage detected