Files
callstack__agent-device/test/integration/ios-simulator-e2e/fixture-identifier-coverage.ts
Michał Pierzchała 117cf4ff68 test(ios): fix nightly fixture selector drift (#1492)
* test(ios): fix nightly fixture selector drift

* test(ios): harden fixture selector coverage
2026-07-30 12:14:57 +02:00

29 lines
873 B
TypeScript

export function findMissingFixtureIdentifiers(
fixtureSources: readonly string[],
liveScenarioSources: readonly string[],
): string[] {
const fixtureIdentifiers = new Set(
fixtureSources.flatMap((source) =>
[...source.matchAll(/\btestID="([^"]+)"/g)].map((match) => match[1]),
),
);
const liveScenarioIdentifiers = new Set(
liveScenarioSources.flatMap(extractLiteralFixtureIdentifiers),
);
return [...liveScenarioIdentifiers]
.filter((identifier) => !fixtureIdentifiers.has(identifier))
.sort();
}
function extractLiteralFixtureIdentifiers(source: string): string[] {
return [
...[...source.matchAll(/\bid=(["'])([^"'$]+)\1/g)].flatMap((match) =>
match[2] ? [match[2]] : [],
),
...[...source.matchAll(/\bidentifier\s*===\s*(["'])([^"']+)\1/g)].flatMap((match) =>
match[2] ? [match[2]] : [],
),
];
}