A lightweight unit testing toolkit for Amazon States Language.
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,
});
});
});
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
.
- Amazon States Language specification https://states-language.net/spec.html
- Amazon States Language - AWS Step Functions https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html
At 2022, AWS Step Functions Local is a primary choice to test ASL locally. See "Testing Step Functions State Machines Locally".
- airware/stepfunctions-local
- wmfs/statebox
- mikeparisstuff/stateslang-js
- coinbase/step (Golang)
- validators