https://github.com/oshikiri/fake-step-functions
An unit testing toolkit for Amazon States Language
https://github.com/oshikiri/fake-step-functions
amazon-states-language aws-step-functions testing-framework unit-testing
Last synced: 5 months ago
JSON representation
An unit testing toolkit for Amazon States Language
- Host: GitHub
- URL: https://github.com/oshikiri/fake-step-functions
- Owner: oshikiri
- License: apache-2.0
- Created: 2018-11-17T14:42:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-11-18T13:47:16.000Z (7 months ago)
- Last Synced: 2025-11-18T16:19:03.004Z (7 months ago)
- Topics: amazon-states-language, aws-step-functions, testing-framework, unit-testing
- Language: TypeScript
- Homepage:
- Size: 1000 KB
- Stars: 15
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fake-step-functions
=====
A lightweight unit testing toolkit for Amazon States Language.
[](https://github.com/oshikiri/fake-step-functions/actions)
[](https://badge.fury.io/js/fake-step-functions)
```js
const { FakeStateMachine } = require('fake-step-functions');
describe('FakeStateMachine.run', () => {
const definition = {
Comment: 'https://states-language.net/spec.html#data',
StartAt: 'AddNumbers',
States: {
AddNumbers: {
Type: 'Task',
Resource: 'arn:aws:lambda:us-east-1:123456789012:function:Add',
InputPath: '$.numbers',
ResultPath: '$.sum',
End: true,
},
},
};
const fakeResources = {
'arn:aws:lambda:us-east-1:123456789012:function:Add': numbers => numbers.val1 + numbers.val2,
};
const fakeStateMachine = new FakeStateMachine(definition, fakeResources);
test('should execute the state machine with fakeResource', async () => {
const runStateResult = await fakeStateMachine.run({
title: 'Numbers to add',
numbers: { val1: 3, val2: 4 },
});
expect(runStateResult.data).toEqual({
title: 'Numbers to add',
numbers: { val1: 3, val2: 4 },
sum: 7,
});
});
});
```
## Release
In order to release new version to npm, create a commit using `npm version patch -m "Release %s"` and push it.
See the npm-publish-action step in `.github/workflows/publish.yml`.
## References
### Specifications
- Amazon States Language specification
- Amazon States Language - AWS Step Functions
### Similar projects
At 2022, **AWS Step Functions Local** is a primary choice to test ASL locally.
See ["Testing Step Functions State Machines Locally"](https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.html).
- [airware/stepfunctions\-local](https://github.com/airware/stepfunctions-local)
- [wmfs/statebox](https://github.com/wmfs/statebox)
- [mikeparisstuff/stateslang\-js](https://github.com/mikeparisstuff/stateslang-js)
- [coinbase/step](https://github.com/coinbase/step) (Golang)
- validators
- [airware/asl\-validator](https://github.com/airware/asl-validator)
- [awslabs/statelint](https://github.com/awslabs/statelint) (Ruby)