Return function result from passes alongside assertion result

This commit is contained in:
Michael B. Gale
2026-07-13 10:08:15 +01:00
parent f181d70282
commit 75773288da

View File

@@ -357,6 +357,11 @@ class EnvBuilder<
}
}
export interface PassedAssertion<R, T> {
result: Awaited<R>;
assertionResult: T;
}
class CallableEnvBuilder<
Args extends readonly any[],
R,
@@ -396,7 +401,7 @@ class CallableEnvBuilder<
public async passes<AArgs extends readonly any[], AResult>(
assertion: (val: Awaited<R>, ...assertionArgs: AArgs) => AResult,
...assertionArgs: AArgs
): Promise<AResult> {
): Promise<PassedAssertion<R, AResult>> {
// this.call() may or may not return a promise,
// `Promise.resolve` turns the result into one if it isn't already,
// and we then await it. That ensures that `result` is an `Awaited<R>`.
@@ -410,8 +415,8 @@ class CallableEnvBuilder<
await delayedCheck(this);
}
// Return the result of the main assertion.
return assertionResult;
// Return the results of the function call and the main assertion.
return { result, assertionResult };
}
/**