Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: statelyai/xstate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @xstate/immer@0.3.1
Choose a base ref
...
head repository: statelyai/xstate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @xstate/immer@0.3.2
Choose a head ref
Loading
Showing 473 changed files with 52,322 additions and 19,649 deletions.
5 changes: 5 additions & 0 deletions .changeset-xstate-test-alpha/.flat-melons-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xstate/test': patch
---

Narrow down the `event` type passed to `EventExecutor` from the corresponding key of the `events` object
9 changes: 9 additions & 0 deletions .changeset-xstate-test-alpha/.flat-trees-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@xstate/test': patch
---

author: @Andarist
pr: #3367
commit: b8cf8cfdc

Fixed `getShortestPathsTo` issue that caused candidate paths to be incorrectly removed while deduplicating generated paths.
5 changes: 5 additions & 0 deletions .changeset-xstate-test-alpha/.good-countries-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xstate/test': minor
---

Improved test output by removing id from description
10 changes: 10 additions & 0 deletions .changeset-xstate-test-alpha/.mighty-terms-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@xstate/graph': patch
'@xstate/test': patch
---

The `serializeState()` path traversal option now provides 3 arguments to the function passed in:

1. `state` - the current state
2. `event` - the event that caused traversal to this state
3. `prevState` 🆕 - the state before the current state (may be `undefined`)
13 changes: 13 additions & 0 deletions .changeset-xstate-test-alpha/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.6.3/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "statelyai/xstate" }],
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"ignore": ["@xstate/analytics", "@xstate/scxml"],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true,
"useCalculatedVersionForSnapshots": true
}
}
8 changes: 8 additions & 0 deletions .changeset-xstate-test-alpha/curly-windows-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@xstate/graph': major
---

pr: #3036
author: @davidkpiano

Renamed `getAdjacencyMap` to `getValueAdjacencyMap`.
10 changes: 10 additions & 0 deletions .changeset-xstate-test-alpha/curly-windows-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@xstate/graph': major
---

pr: #3036
author: @davidkpiano

Changed `getSimplePaths` to `getSimplePlans`, and `getShortestPaths` to `getShortestPlans`. Both of these functions can be passed a machine, and return `StatePlan[]`.

Added functions `traverseSimplePlans`, `traverseShortestPlans`,`traverseShortestPlansFromTo`, `traverseSimplePlansTo` and `traverseSimplePlansFromTo`, which can be passed a `Behavior` and return `StatePlan[]`.
12 changes: 12 additions & 0 deletions .changeset-xstate-test-alpha/great-lions-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@xstate/test': major
---

pr: #3036

author: @mattpocock
author: @davidkpiano

Substantially simplified how paths and plans work in `TestModel`. Changed `getShortestPlans` and `getSimplePlans` to `getShortestPaths` and `getSimplePaths`. These functions now return an array of paths, instead of an array of plans which contain paths.

Also added `getPaths`, which defaults to `getShortestPaths`. This can be passed a `pathGenerator` to customize how paths are generated.
37 changes: 37 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-brand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
'@xstate/test': major
---

pr: #3036
author: @mattpocock

Moved event cases out of `events`, and into their own attribute called `eventCases`:

```ts
const model = createTestModel(machine, {
eventCases: {
CHOOSE_CURRENCY: [
{
currency: 'GBP'
},
{
currency: 'USD'
}
]
}
});

model.getPaths().forEach((path) => {
it(path.description, async () => {
await path.test({
events: {
CHOOSE_CURRENCY: ({ event }) => {
console.log(event.currency);
}
}
});
});
});
```

`eventCases` will also now always produce a new path, instead of only creating a path for the first case which matches.
8 changes: 8 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-bread.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@xstate/test': major
---

pr: #3036
author: @davidkpiano

Removed `.testCoverage()`, and instead made `getPlans`, `getShortestPlans` and `getSimplePlans` cover all states and transitions enabled by event cases by default.
10 changes: 10 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-grand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@xstate/test': major
---

pr: #3036
author: @davidkpiano

Added validation on `createTestModel` to ensure that you don't include invalid machine configuration in your test machine. Invalid machine configs include `invoke`, `after`, and any actions with a `delay`.

Added `createTestMachine`, which provides a slimmed-down API for creating machines which removes these types from the config type signature.
47 changes: 47 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-grate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
'@xstate/test': major
---

pr: #3036
author: @davidkpiano

`getShortestPaths()` and `getPaths()` will now traverse all _transitions_ by default, not just all events.

Take this machine:

```ts
const machine = createTestMachine({
initial: 'toggledOn',
states: {
toggledOn: {
on: {
TOGGLE: 'toggledOff'
}
},
toggledOff: {
on: {
TOGGLE: 'toggledOn'
}
}
}
});
```

In `@xstate/test` version 0.x, this would run this path by default:

```txt
toggledOn -> TOGGLE -> toggledOff
```

This is because it satisfies two conditions:

1. Covers all states
2. Covers all events

But this a complete test - it doesn't test if going from `toggledOff` to `toggledOn` works.

Now, we seek to cover all transitions by default. So the path would be:

```txt
toggledOn -> TOGGLE -> toggledOff -> TOGGLE -> toggledOn
```
9 changes: 9 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-great.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@xstate/test': minor
---

pr: #3036
author: @mattpocock
author: @davidkpiano

Added `path.testSync(...)` to allow for testing paths in sync-only environments, such as Cypress.
29 changes: 29 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@xstate/test': major
---

pr: #3036
author: @mattpocock
author: @davidkpiano

Moved `events` from `createTestModel` to `path.test`.

Old:

```ts
const model = createTestModel(machine, {
events: {}
});
```

New:

```ts
const paths = model.getPaths().forEach((path) => {
path.test({
events: {}
});
});
```

This allows for easier usage of per-test mocks and per-test context.
22 changes: 22 additions & 0 deletions .changeset-xstate-test-alpha/lazy-turtles-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@xstate/test': major
---

pr: #3036
author: @mattpocock
author: @davidkpiano

Added `states` to `path.test()`:

```ts
const paths = model.getPaths().forEach((path) => {
path.test({
states: {
myState: () => {},
'myState.deep': () => {}
}
});
});
```

This allows you to define your tests outside of your machine, keeping the machine itself easy to read.
29 changes: 29 additions & 0 deletions .changeset-xstate-test-alpha/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"mode": "pre",
"tag": "alpha",
"initialVersions": {
"xstate": "4.32.1",
"@xstate/analytics": "0.0.1",
"@xstate/fsm": "2.0.0",
"@xstate/graph": "2.0.0-alpha.0",
"@xstate/immer": "0.3.1",
"@xstate/inspect": "0.7.0",
"@xstate/react": "3.0.0",
"@xstate/scxml": "0.2.1",
"@xstate/svelte": "2.0.0",
"@xstate/test": "1.0.0-alpha.0",
"@xstate/vue": "2.0.0"
},
"changesets": [
"curly-windows-burn",
"curly-windows-learn",
"great-lions-buy",
"lazy-turtles-brand",
"lazy-turtles-bread",
"lazy-turtles-grand",
"lazy-turtles-grate",
"lazy-turtles-great",
"lazy-turtles-mate",
"lazy-turtles-trade"
]
}
3 changes: 2 additions & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -6,5 +6,6 @@
"packages/xstate-react",
"packages/xstate-test"
],
"sandboxes": ["xstate-example-template-m4ckv", "xstate-react-template-3t2tg"]
"sandboxes": ["xstate-example-template-m4ckv", "xstate-react-template-3t2tg"],
"node": "16"
}
29 changes: 0 additions & 29 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -2,12 +2,11 @@ name: Bug Report
description: File a bug report
title: "Bug: "
labels: [bug, triage]
assignees:
body:
- type: markdown
attributes:
value: |
Report an issue with XState or any XState-related tooling.
Report an issue with XState or XState tooling within this repo.
- type: textarea
id: description
attributes:
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: ✨ Feature Request
url: https://github.com/statelyai/xstate/discussions/new
15 changes: 15 additions & 0 deletions .github/actions/ci-checks/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'CI checks'
runs:
using: 'composite'
steps:
- name: Build
run: yarn build
shell: bash

- name: Test
run: yarn test --silent
shell: bash

- name: Svelte Check
run: yarn --cwd packages/xstate-svelte svelte-check
shell: bash
12 changes: 12 additions & 0 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'CI setup'
runs:
using: 'composite'
steps:
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install Dependencies
run: yarn
shell: bash
Loading