Skip to content

Commit d9e4f06

Browse files
committed
refactor(snapshot): isolate empty-scope admission
1 parent 04e7f9f commit d9e4f06

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/platforms/apple/interactor.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,7 @@ async function captureAppleRunnerSnapshot(
184184
),
185185
);
186186
const nodes = result.nodes ?? [];
187-
const isValidEmptyScope =
188-
normalizeSnapshotScope(options?.scope) !== null &&
189-
result.quality !== undefined &&
190-
result.quality.state !== 'sparse';
187+
const isValidEmptyScope = acceptsEmptyScopedSnapshot(options, result.quality);
191188
if (nodes.length === 0 && device.kind === 'simulator' && !isValidEmptyScope) {
192189
throw new AppError('COMMAND_FAILED', 'XCTest snapshot returned 0 nodes on iOS simulator.');
193190
}
@@ -201,6 +198,15 @@ async function captureAppleRunnerSnapshot(
201198
};
202199
}
203200

201+
function acceptsEmptyScopedSnapshot(
202+
options: SnapshotOptions | undefined,
203+
quality: SnapshotQualityVerdict | undefined,
204+
): boolean {
205+
return (
206+
normalizeSnapshotScope(options?.scope) !== null && quality?.state !== 'sparse' && !!quality
207+
);
208+
}
209+
204210
function mergeRunnerCallSignal(
205211
options: RunnerCallOptions,
206212
signal: AbortSignal | undefined,

0 commit comments

Comments
 (0)