Skip to content

createTestModel

Callable


  • Creates a test model that represents an abstract model of a system under test (SUT).

    The test model is used to generate test paths, which are used to verify that states in the machine are reachable in the SUT.

    @example
    const toggleModel = createModel(toggleMachine).withEvents({
    TOGGLE: {
    exec: async page => {
    await page.click('input');
    }
    }
    });

    Type parameters

    Parameters

    • machine: TMachine

      The state machine used to represent the abstract model.

    • optionaloptions: Partial<TestModelOptions<SnapshotFrom<TMachine>, ResolveEventType<TMachine>>>

      Options for the created test model:

      • events: an object mapping string event types (e.g., SUBMIT) to an event test config (e.g., {exec: () => {...}, cases: [...]})

    Returns TestModel<SnapshotFrom<TMachine>, EventFrom<TMachine>, unknown>