History

Type the recorder wait timeout as a tagged error

Rhys Sullivan committed 4 months ago

Commit 19e23891 parent 5f8a25d1 file · +8 −3Browse files

Unified · Split

packages/plugins/graphql/src/testing/index.ts+8−3
@@ -55,6 +55,12 @@ export interface GraphqlTestServerShape { · 54 unmodified lines
5555 readonly clearRequests: Effect.Effect<void>;
5656 }
5757
58+export class GraphqlTestRecorderTimeoutError extends Data.TaggedError(
59+ "GraphqlTestRecorderTimeoutError",
60+)<{
61+ readonly message: string;
62+}> {}
63+
5864 /** Poll the request recorder until `predicate` matches. Yoga captures requests
5965 * asynchronously (`captureRequest` runs via `Effect.runPromise` in the handler
6066 * context), so connect/invoke can resolve before the ref updates under load. */
@@ -62,14 +68,13 @@ export const waitForRecordedRequests = ( · 1 unmodified line
6268 requests: Effect.Effect<readonly GraphqlTestRequest[]>,
6369 predicate: (requests: readonly GraphqlTestRequest[]) => boolean,
6470 message = "timed out waiting for matching recorded GraphQL requests",
65−): Effect.Effect<readonly GraphqlTestRequest[]> =>
71+): Effect.Effect<readonly GraphqlTestRequest[], GraphqlTestRecorderTimeoutError> =>
6672 requests.pipe(
6773 Effect.filterOrFail(
6874 (all) => predicate(all),
69− () => message,
75+ () => new GraphqlTestRecorderTimeoutError({ message }),
7076 ),
7177 Effect.retry(Schedule.both(Schedule.spaced("50 millis"), Schedule.recurs(100))),
72− Effect.orDie,
7378 );
7479
7580 class GraphqlTestServerAddressError extends Data.TaggedError("GraphqlTestServerAddressError")<{