npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sfn-test

v1.5.0

Published

AI-powered local testing tool for AWS Step Functions

Readme

sfn-ai-local-test

AI-powered local testing tool for AWS Step Functions

A powerful tool for locally executing and testing AWS Step Functions state machines.

✨ Key Features

  • 🚀 Fast Execution: TypeScript-based state machine interpreter
  • 🤖 AI Support: Automatic mock/test case generation via Claude API
  • 🧪 Comprehensive Testing: YAML-based regression test suites
  • 📊 Coverage Measurement: Automatic execution path coverage calculation and visualization
  • 🔄 Full Support: Both JSONPath and JSONata support, all state types supported
  • 🏗️ CDK Integration: Automatic ASL extraction from CDK output

📦 Installation

npm install -g sfn-test

🚀 Quick Start

  1. Initialize Project

    # Set Claude API key
    export ANTHROPIC_API_KEY="your-api-key"
       
    # Initialize project
    sfn-test init
  2. Extract ASL from CDK (for CDK projects)

    sfn-test extract
  3. Generate Mocks and Tests (AI-assisted)

    sfn-test generate mock --name my-workflow
    sfn-test generate test --name my-workflow
  4. Run Tests

    # Run all tests
    sfn-test run
       
    # Run with coverage
    sfn-test run --cov

🛠️ Basic Commands

| Command | Description | |---------|-------------| | sfn-test init | Initialize project (interactive) | | sfn-test extract | Extract ASL definitions from CDK/CloudFormation | | sfn-test extract --cdk <path> | Extract from specific CDK synth output | | sfn-test extract --cdk-out <dir> | Extract from CDK output directory | | sfn-test generate mock --name <name> | Generate mock configuration with AI | | sfn-test generate mock --max-attempts 3 | Generate mock with retry count | | sfn-test generate test --name <name> | Generate test cases with AI | | sfn-test generate test --max-attempts 3 | Generate test with retry count | | sfn-test run | Run all test suites | | sfn-test run --name <name> | Run single state machine | | sfn-test run --suite <path> | Run specific test suite file | | sfn-test run --cov | Run with coverage measurement |

📚 Documentation

📖 Detailed Guides

🔧 Examples and Samples

⚙️ For Developers

# Install dependencies
npm install

# Development mode
npm run dev

# Quality check
npm run check

# Run tests
npm test

🔍 Supported Features

✅ Supported State Types

  • Task - Lambda integration with optimized patterns
  • Choice - Conditional branching
  • Wait - Wait processing
  • Succeed/Fail - Terminal states
  • Pass - Data transformation
  • Parallel - Parallel processing
  • Map - Array processing
  • Distributed Map - Large-scale data processing (ItemReader/ItemBatcher/ResultWriter support)
  • Retry/Catch - Error handling

🎯 Main Features

  • JSONPath/JSONata Support - Full support for expression languages
  • Mock Configuration - Fixed values, conditional branching, stateful, error simulation
  • External Data Integration - Data loading from JSON/CSV/JSONL/YAML files
  • Execution Path Validation - Complex branch path validation
  • Coverage Measurement - Automatic execution path coverage calculation
  • Report Output - Console/JSON/JUnit format result output

🤖 AI Generation Features

Automatic Timeout Adjustment

Automatically analyzes state machine complexity and sets appropriate timeout values.

Calculation Logic:

Base time: 60s + (state count × 2s)
Complexity factors:
  - Map states: × 1.5 (up to 3 compounded)
  - DistributedMap states: × 2.0 (up to 2 compounded)
  - Parallel states: × 1.3 (up to 3 compounded)
  - JSONata usage: × 1.3
  - Variables usage: × 1.2
  - Deep nesting (4+ levels): × 1.5
Maximum: 10 minutes

Retry Feature (GenerationRetryManager)

AI-generated content is automatically validated and regenerated with progressive feedback if issues are found.

  • 1st failure: Concise and friendly suggestions
  • 2nd failure: More detailed and emphasized suggestions
  • 3rd+ failures: Strict mode with all errors shown in detail
# Default: up to 2 attempts
sfn-test generate mock --asl ./state-machine.json

# Change maximum attempts
sfn-test generate mock --asl ./state-machine.json --max-attempts 3

# Manual timeout specification (disables auto-calculation)
sfn-test generate mock --asl ./state-machine.json --timeout 600000

🤝 Contributing

Issues and Pull Requests are welcome!

📞 Support

📄 License

MIT


Initial release v1.0.0