Installations
npm install @xstate/test
Developer Guide
Typescript
Yes
Module System
CommonJS, UMD
Node Version
14.18.3
NPM Version
6.14.15
Score
96.1
Supply Chain
99.1
Quality
79.7
Maintenance
100
Vulnerability
100
License
Releases
@xstate/solid@1.0.2
Published on 12 Jan 2025
xstate@5.19.2
Published on 12 Jan 2025
@xstate/vue@4.0.2
Published on 12 Jan 2025
@xstate/svelte@4.0.3
Published on 12 Jan 2025
@xstate/react@5.0.2
Published on 12 Jan 2025
@xstate/graph@3.0.2
Published on 12 Jan 2025
Contributors
Languages
TypeScript (97.71%)
Vue (0.82%)
JavaScript (0.67%)
Svelte (0.45%)
CSS (0.27%)
HTML (0.08%)
Developer
Download Statistics
Total Downloads
5,818,110
Last Day
5,265
Last Week
21,561
Last Month
96,617
Last Year
1,396,960
GitHub Statistics
27,724 Stars
6,744 Commits
1,276 Forks
189 Watching
276 Branches
339 Contributors
Bundle Size
13.49 kB
Minified
4.47 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.5.1
Package Id
@xstate/test@0.5.1
Unpacked Size
70.95 kB
Size
10.88 kB
File Count
20
NPM Version
6.14.15
Node Version
14.18.3
Total Downloads
Cumulative downloads
Total Downloads
5,818,110
Last day
-13.9%
5,265
Compared to previous day
Last week
-11.2%
21,561
Compared to previous week
Last month
13.5%
96,617
Compared to previous month
Last year
-13.5%
1,396,960
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
1
Dev Dependencies
6
@xstate/test
This package contains utilities for facilitating model-based testing for any software.
Talk
Write Fewer Tests! From Automation to Autogeneration at React Rally 2019 (🎥 Video)
Quick Start
- Install
xstate
and@xstate/test
:
1npm install xstate @xstate/test
- Create the machine that will be used to model the system under test (SUT):
1import { createMachine } from 'xstate'; 2 3const toggleMachine = createMachine({ 4 id: 'toggle', 5 initial: 'inactive', 6 states: { 7 inactive: { 8 on: { 9 TOGGLE: 'active' 10 } 11 }, 12 active: { 13 on: { 14 TOGGLE: 'inactive' 15 } 16 } 17 } 18});
- Add assertions for each state in the machine (in this example, using Puppeteer):
1// ... 2 3const toggleMachine = createMachine({ 4 id: 'toggle', 5 initial: 'inactive', 6 states: { 7 inactive: { 8 on: { 9 /* ... */ 10 }, 11 meta: { 12 test: async (page) => { 13 await page.waitFor('input:checked'); 14 } 15 } 16 }, 17 active: { 18 on: { 19 /* ... */ 20 }, 21 meta: { 22 test: async (page) => { 23 await page.waitFor('input:not(:checked)'); 24 } 25 } 26 } 27 } 28});
- Create the model:
1import { createMachine } from 'xstate'; 2import { createModel } from '@xstate/test'; 3 4const toggleMachine = createMachine(/* ... */); 5 6const toggleModel = createModel(toggleMachine).withEvents({ 7 TOGGLE: { 8 exec: async (page) => { 9 await page.click('input'); 10 } 11 } 12});
- Create test plans and run the tests with coverage:
1// ... 2 3describe('toggle', () => { 4 const testPlans = toggleModel.getShortestPathPlans(); 5 6 testPlans.forEach((plan) => { 7 describe(plan.description, () => { 8 plan.paths.forEach((path) => { 9 it(path.description, async () => { 10 // do any setup, then... 11 12 await path.test(page); 13 }); 14 }); 15 }); 16 }); 17 18 it('should have full coverage', () => { 19 return toggleModel.testCoverage(); 20 }); 21});
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
21 commit(s) and 10 issue activity found in the last 90 days -- score normalized to 10
Reason
GitHub workflow tokens follow principle of least privilege
Details
- Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:16
- Info: topLevel 'contents' permission set to 'read': .github/workflows/nodejs.yml:13
- Info: found token with 'none' permissions: .github/workflows/release.yml:1
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
Found 11/23 approved changesets -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/statelyai/xstate/nodejs.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/statelyai/xstate/release.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/statelyai/xstate/release.yml/main?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 19 are checked with a SAST tool
Reason
84 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-qxrj-hx23-xp82
- Warn: Project is vulnerable to: GHSA-mv48-hcvh-8jj8
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-vc8w-jr9v-vj7f
- Warn: Project is vulnerable to: GHSA-hqq7-2q2v-82xq
- Warn: Project is vulnerable to: GHSA-q8gg-vj6m-hgmj
- Warn: Project is vulnerable to: GHSA-7q7g-4xm8-89cq
- Warn: Project is vulnerable to: GHSA-h452-7996-h45h
- Warn: Project is vulnerable to: GHSA-36jr-mh4h-2g58
- Warn: Project is vulnerable to: GHSA-p3vf-v8qc-cwcr
- Warn: Project is vulnerable to: GHSA-gx9m-whjm-85jf
- Warn: Project is vulnerable to: GHSA-mmhx-hmjr-r674
- Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-8mmm-9v2q-x3f9
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-7wwv-vh3v-89cq
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-8g7p-74h8-hg48
- Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-6vfc-qv3f-vr6c
- Warn: Project is vulnerable to: GHSA-x3vm-38hw-55wf
- Warn: Project is vulnerable to: GHSA-m4gq-x24j-jpmf
- Warn: Project is vulnerable to: GHSA-wrvr-8mpx-r7pp
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5g97-whc9-8g7j
- Warn: Project is vulnerable to: GHSA-8r4g-cg4m-x23c
- Warn: Project is vulnerable to: GHSA-6fw4-hr69-g3rv
- Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-3f95-r44v-8mrg
- Warn: Project is vulnerable to: GHSA-28xr-mwxg-3qc8
- Warn: Project is vulnerable to: GHSA-9p95-fxvg-qgq2
- Warn: Project is vulnerable to: GHSA-9w5j-4mwv-2wj8
- Warn: Project is vulnerable to: GHSA-pqhp-25j4-6hq9
- Warn: Project is vulnerable to: GHSA-8225-6cvr-8pqp
- Warn: Project is vulnerable to: GHSA-8266-84wp-wv5c
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
Score
5.2
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @xstate/test
xstate-test-cypress
Utilities for adapting @xstate/test to work more easily with cypress 7+
xstate-test
Testing utilities for XState
@smartive/xstate-test-toolbox
This package contains the helper `createTestPlans` which can be used with xstate and @xstate/test.
qunit-xstate-test
Use @xstate/test with QUnit