Skip to content

Commit 30c33c9

Browse files
committed
Make results of function call available to delayed checks
1 parent 3ca82bb commit 30c33c9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/testing-utils.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ import { ActionName } from "./status-report";
3434
import {
3535
DEFAULT_DEBUG_ARTIFACT_NAME,
3636
DEFAULT_DEBUG_DATABASE_NAME,
37+
Failure,
3738
getEnv,
3839
GitHubVariant,
3940
GitHubVersion,
4041
HTTPError,
4142
resetCachedCodeQlVersion,
43+
Result,
44+
Success,
4245
} from "./util";
4346

4447
export const SAMPLE_DOTCOM_API_DETAILS = {
@@ -226,7 +229,10 @@ type DelayedCheck<
226229
Args extends readonly any[],
227230
R,
228231
Fs extends ReadonlyArray<AllState[number]>,
229-
> = (env: Readonly<BaseEnvBuilder<Args, R, Fs>>) => Promise<any>;
232+
> = (
233+
env: Readonly<BaseEnvBuilder<Args, R, Fs>>,
234+
result: Result<Awaited<R>, ThrownError<ErrorConstructor | Error>>,
235+
) => Promise<any>;
230236

231237
export type Mutation<T> = (val: T) => void;
232238
export type ValueOrMutation<T> = T | Mutation<T>;
@@ -441,7 +447,7 @@ class CallableEnvBuilder<
441447

442448
// Run other delayed checks.
443449
for (const delayedCheck of this.checks) {
444-
await delayedCheck(this);
450+
await delayedCheck(this, new Success(result));
445451
}
446452

447453
// Return the results of the function call and the main assertion.
@@ -467,7 +473,7 @@ class CallableEnvBuilder<
467473

468474
// Run other delayed checks.
469475
for (const delayedCheck of this.checks) {
470-
await delayedCheck(this);
476+
await delayedCheck(this, new Failure(error));
471477
}
472478

473479
// Return the error.

0 commit comments

Comments
 (0)