NaNoWriMo Promotes Manuscription

    @wheatstalk/cdk-assert-state
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.21 • Public • Published

    AWS CDK Assert State

    This construct lib provides AssertState, a Step Functions State Machine state that uses expect-like assertions to check input.

    import { App, Stack } from 'aws-cdk-lib';
    import { Chain, Pass, StateMachine } from 'aws-cdk-lib/aws-stepfunctions';
    import { Assert, AssertState, Expr } from '@wheatstalk/cdk-assert-state';
    
    const app = new App();
    const stack = new Stack(app, 'integ-cdk-sfn-integ');
    
    const input = new Pass(stack, 'TestInput', {
      parameters: {
        integ: true,
        number: 1,
      },
    });
    
    const expect = new AssertState(stack, 'TestAssert', {
      assert: Assert.expressions([
        Expr.expect(Expr.input()).toEqual(
          Expr.objectContaining({
            integ: true,
            number: Expr.anything(),
          }),
        ),
        Expr.expect(Expr.input('number')).not.toEqual(2),
      ]),
    });
    
    new StateMachine(stack, 'Test', {
      definition: Chain.start(input)
        .next(expect),
    });

    Keywords

    Install

    npm i @wheatstalk/cdk-assert-state

    DownloadsWeekly Downloads

    6

    Version

    0.0.21

    License

    Apache-2.0

    Unpacked Size

    796 kB

    Total Files

    23

    Last publish

    Collaborators

    • misterjoshua