sukima / qunit-xstate-test

@xstate/test support for QUnit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

qunit-xstate-test

QUnit integration with @xstate/test

import { module } from 'qunit';
import { setupXStateTest, testShortestPaths } from 'qunit-xstate-test';
import { Machine } from 'xstate';
import { createModel } from '@xstate/test';

const testModel = createModel(
  Machine({
    // ...
    states: {
      'state-name': {
        meta: { 
          async test({ assert }) {
            assert.equal(/* assert something about your state */);
          }
        }
      }
    }
  })
);

module('Testing my State Machine', function(hooks) {
  setupXStateTest(hooks, testModel);

  testShortestPaths(testModel, (assert, path) => {
    // set up for your tests
    // ...
    // pass `assert` to your meta.test context
    return path.test({ assert });
  });
});

NOTE: setupXStateTest defines an after hook that checks your state machine's test coverage.

Examples:

Installation

yarn add --dev qunit-xstate-test
npm install --save-dev qunit-xstate-test

Ember Projects

Requirements: ember-auto-import

Contributing

See the Contributing guide for details.

Prior Art

  • qunit-dom much of the config for this repo was taken from qunit-dom.

License

This project is licensed under the MIT License.

About

@xstate/test support for QUnit

License:MIT License


Languages

Language:JavaScript 49.6%Language:TypeScript 32.4%Language:HTML 15.6%Language:Shell 2.5%