diff --git a/src/commands/synthetics/utils/internal.ts b/src/commands/synthetics/utils/internal.ts index 6b6700a28..426198932 100644 --- a/src/commands/synthetics/utils/internal.ts +++ b/src/commands/synthetics/utils/internal.ts @@ -49,6 +49,9 @@ export const hasResultPassed = ( return result.status === 'passed' } +/** + * Whether the result is of type {@link BaseResult}, i.e. it wasn't skipped. + */ export const isBaseResult = (result: Result): result is BaseResult => { return !isResultSkippedBySelectiveRerun(result) } @@ -57,6 +60,16 @@ export const hasDefinedResult = (result: Result): result is BaseResult & {result return !isResultSkippedBySelectiveRerun(result) && result.result !== undefined } +/** + * Whether the result has a defined {@link BaseResult.result} property. + * + * This property would be undefined if the server result isn't available when polling for it, + * which is a known latency issue. We call such result an incomplete result. + */ +export const hasDefinedResult = (result: Result): result is BaseResult & {result: ServerResult} => { + return isBaseResult(result) && result.result !== undefined +} + /** * When the test is configured to be retried and the first attempt fails, `retries` is set to `0` * and the result is kept `in_progress` until the final result is received.