MCPcopy
hub / github.com/statelyai/xstate / runW3TestToCompletion

Function runW3TestToCompletion

packages/core/test/scxml.test.ts:355–385  ·  view source on GitHub ↗
(machine: AnyStateMachine)

Source from the content-addressed store, hash-verified

353}
354
355async function runW3TestToCompletion(machine: AnyStateMachine): Promise<void> {
356 const { resolve, reject, promise } = Promise.withResolvers<void>();
357 let nextState: AnyMachineSnapshot;
358 let prevState: AnyMachineSnapshot;
359
360 const actor = createActor(machine, {
361 logger: () => void 0
362 });
363 actor.subscribe({
364 next: (state) => {
365 prevState = nextState;
366 nextState = state;
367 },
368 complete: () => {
369 // Add 'final' for test230.txml which does not have a 'pass' state
370 if (['final', 'pass'].includes(nextState.value as string)) {
371 resolve();
372 } else {
373 reject(
374 new Error(
375 `Reached "fail" state from state ${JSON.stringify(
376 prevState?.value
377 )}`
378 )
379 );
380 }
381 }
382 });
383 actor.start();
384 return promise;
385}
386
387async function runTestToCompletion(
388 machine: AnyStateMachine,

Callers 1

runTestToCompletionFunction · 0.85

Calls 3

createActorFunction · 0.90
subscribeMethod · 0.65
startMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…