Skip to content

Step Functions spies #32

@bboure

Description

@bboure

As a user, I want to be able to spy on step function executions.

basic usage:

const spy = stepFunctionsSpy({
  executionName: 'my-sf-exec'
});

proposed matchers:

.toSucceed()
.toSucceedWithResultMatchingObject({})
.toSucceedWithResultMatchingSnapshot({})
.toSucceedWithResultMatchingInlineSnapshot({})
.toFail()
.toFailWithErrorMatchingObject({})
.toFailWithErrorMatchingSnapshot({})
.toFailWithErrorMatchingInlineSnapshot({})
.toHaveGoneThroughState('stateId');
.toHaveGoneThroughStateWithInputMatchinObject('stateId', {});
.toHaveGoneThroughStateWithOuputMatchinObject('stateId', {});

special usages, due to snapshot limitations (i.e.: snapshots must be the first argument of the matcher): we can expose all transitions from the execution history (similar to spy.mock.calls) and use jest "native" jest matchers.

expect(spy.states['stateId'].input).toMatchSnapshot()
expect(spy.states['stateId'].output).toMatchSnapshot()

limitations of ☝️ : user will need to first await for the execution to finish. e.g. with expect(spy).toSucceed()

TBD:
some sates might be called more than once or contain several iterations (e.g. Map, loops, states transitioning back, etc.).
we need to think how to deal with those.
maybe

.toHaveGoneThroughStateN('stateId', 5)

and

expect(spy.states['stateId'][0].output).toMatchSnapshot()
expect(spy.states['stateId'][1].output).toMatchSnapshot()

we also probably want to keep a log of the order of execution (i.e. execution history) to do things like:

  • assert that X happened before Y
  • was the nth transition X ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions