@mst-ds/mst-jest

1.0.0 • Public • Published

mst-jest

API

createMSTSnapshot(node) - created jest snapshot from model
getEnvMock({...}) - mocked for getEnv'
getRootMock({...}) - mocked for getRoot'
onPatchesAggregation(node) - aggregate all model patches, and take a jest snapshot'
onSnapshotAggregation(node) - aggregate all model snapshots, and take a jest snapshot'

Usage

import { types } from "mobx-state-tree"
import { createMSTSnapshot, onPatchesAggregation, onSnapshotAggregation } from "@mst-ds/mst-jest"

describe('Tests', () => {
    it('snapshot test', () => {
        const rootStore = types.model({
            ...,
        })
        .actions(() => {...});

        createMSTSnapshot(list) // create jest snapshot
    });
it('snapshots test', () => {
        const rootStore = types.model({
            ...,
        })
        .actions(() => {...});

        const disposer = onPatchesAggregation(list)

        rootStore.action1();
        rootStore.action2();
        rootStore.action3();

        disposer() // create jest snapshot
    });
    it('patches test', () => {
        const rootStore = types.model({
            ...,
        })
        .actions(() => {...});

        const disposer = onSnapshotAggregation(list)

        rootStore.action1();
        rootStore.action2();
        rootStore.action3();

        disposer() // create jest snapshot
    });
});

Package Sidebar

Install

npm i @mst-ds/mst-jest

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

11.2 kB

Total Files

8

Last publish

Collaborators

  • yurchishin