
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
stepfunctions
Advanced tools
AWS Step Functions implementation in Node, so you can run your Node.js lambda handlers in your test environments. Made to support Serverless JS testing.
AWS Step Functions implementation in Node, so you can run your Node.js lambda handlers in your test environments. Made to support Serverless JS testing.
npm i -D stepfunctions
or if you're using yarn like me:
yarn add -D stepfunctions
I was working on getting step functions orchestrated using Serverless, Lambda, and Step functions and there was no way to run through the statemachine in Jest. So I made the spec, or parts of it, work in JS so that I can spy and mock the statemachine.
I am perfectly aware of the existence of step-functions-offline and local-stepfunctions, but none of those can be orchestrated natively in a testing context.
If you are:
Include it in your test files, tested with Jest so far.
const Sfn = require('stepfunctions');
const sm = new Sfn({
StateMachine: {
StartAt: 'Test',
States: {
Test: {
Type: 'Task',
Resource: 'arn:aws:lambda:ap-southeast-1:123456789012:function:test',
End: true,
},
},
},
});
describe('StateMachine Test', () => {
it('Check if a task was run', async () => {
const mockfn = jest.fn((input) => input.test === 1);
sm.bindTaskResource('Test', mockfn);
await sm.startExecution({ test: 1 });
expect(mockfn).toHaveBeenCalled();
});
});
You can see more examples in /test/stepfunctions.test.js.
sm.startExecution(input, {
respectTime: false,
maxWaitTime: 30,
maxConcurrency: 10,
});
const sm = new Sfn({
StateMachine: {
StartAt: 'HelloWorld',
States: {
HelloWorld: {
Type: 'Task',
Resource: 'arn:aws:lambda:ap-southeast-1:123456789012:function:test',
End: true,
},
},
},
});
sm.bindTaskResource('HelloWorld', (input) => `hello ${input}`);
await sm.startExecution('world');
// will output `hello world`
Must be called before startExecution, binds to Tasks and replaces their handler to the provided Callback parameter.
Must be called after startExecution. This function returns the absolute result from the statemachine if it has finished.
Use console.table to list down the transitions that occured.
abort is made available within the replaced Task handlers made with bindTaskResource. this allows you to abort a call
from within a handler itself.
The spec implemented in https://states-language.net/spec.html is fully supported by this library besides the ones below:
Experimental
The above features are labeled experimental because it cannot be fully spec compliant(yet) due to AWS specific cases.
Wait will wait for at most 30 seconds. This is because it's expected that this library
will be used within a testing context. You can override this behaviour by adding the respectTime option to true in the startExecution method.States.Permissions as the library will not have context on AWS related permissions.PR's are welcome to help finish the ones below :)
sls invoke local instead of binding resolversjest.fakeTimers() in the testyield sm.next()stepfunctions is MIT Licensed
FAQs
AWS Step Functions implementation in Node, so you can run your Node.js lambda handlers in your test environments. Made to support Serverless JS testing.
The npm package stepfunctions receives a total of 18 weekly downloads. As such, stepfunctions popularity was classified as not popular.
We found that stepfunctions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.