-
Notifications
You must be signed in to change notification settings - Fork 0
/
replay.ts
24 lines (21 loc) · 836 Bytes
/
replay.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { SCENARIOS } from "../../scenarios";
import ScenarioContext from "./scenario-context";
import { ScenarioIdentifier, ScenarioReplayDependencies } from "./types";
export function getScenarioMap(identfier: ScenarioIdentifier) {
return SCENARIOS[identfier.modulePath!];
}
export function getScenario(identfier: ScenarioIdentifier) {
const scenarioMap = getScenarioMap(identfier);
return scenarioMap[identfier.scenarioName!];
}
export async function replayScenario(identfier: ScenarioIdentifier, dependencies: ScenarioReplayDependencies) {
const scenario = getScenario(identfier);
const context = new ScenarioContext(dependencies);
const steps = await scenario();
for (const step of steps) {
await step.execute(context);
if (identfier.stepName && step.name === identfier.stepName) {
break;
}
}
}