The Simplest Way to Make Cypress and Step Functions Work Like They Should
Teams pair cypress and step functions to test backend state machines from browser tests. Cypress triggers an app event and checks the cloud workflow until every step finishes. Modern apps do not finish every task during a single web request. Background jobs process orders, send alerts, and update databases over several minutes. When you test only the user interface, you miss failures inside those background steps. Linking your browser test runner with your cloud state machine closes that testin
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams pair cypress and step functions to test backend state machines from browser tests. Cypress triggers an app event and checks the cloud workflow until every step finishes.
Modern apps do not finish every task during a single web request. Background jobs process orders, send alerts, and update databases over several minutes. When you test only the user interface, you miss failures inside those background steps. Linking your browser test runner with your cloud state machine closes that testing gap.
How cypress and step functions share permissions and data
A browser test runs outside your cloud account by default. To check a workflow run, the test runner needs permission to call cloud APIs. The runner sends a request through a background task on the test host. That host uses an IAM role to read the state machine status.
Data flows in two directions during a test run. First, the browser triggers an action in the web app, like submitting a form. The app backend starts a state machine run and returns a unique run ID. Second, the test runner polls the cloud API with that ID to read outputs.
Good tests check both the final state and the data passed between steps. If a step fails, the test reads the error cause from the workflow history. This direct feedback tells developers whether the bug lives in the UI or backend.
Common failure modes and how to scope roles
Many teams start by putting static cloud keys into their test runner settings. Shared service accounts create a big risk when engineers copy them to laptops. If a key leaks, an attacker can start or stop workflows across the account. Broad tokens also allow test scripts to change production data by mistake.
Unlogged queries cause another problem during test failures. When five test runners poll the same state machine, cloud logs get messy fast. Teams cannot tell which test triggered a broken workflow or read sensitive payload data. Sensitive fields like emails or card numbers can also appear in plain test logs.
Cloud Functions IAM + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these issues by scoping roles to the exact state machine resource. Give the test runner role permission to describe runs, not start or delete them. Only the app backend should have permission to start a new workflow run. Keep test runners in a private network path so API calls never cross public routes.
How to handle timing and state polling in tests
Browser tests expect fast responses, while cloud workflows can take minutes to complete. If a test checks the final result right away, the test will fail early. Waiting for a fixed number of seconds makes tests slow and unreliable.
Instead, build a polling loop inside the test runner background task. The task asks the cloud API for the workflow status every few seconds. Once the status changes from running to succeeded, the test moves to the UI check. If the workflow hits a failed state, the test stops right away.
This pattern keeps test suites fast and avoids wasted wait time. It also keeps cloud API calls low so you do not hit rate limits. Clear timeouts make sure a stuck workflow does not hang your build pipeline forever.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Should Cypress start a Step Functions workflow directly?
For end-to-end tests, let the web app trigger the workflow just like production. Direct starts work well only when you test isolated backend state machines without a UI.
How do we stop test logs from exposing sensitive workflow data?
Use data masking to rewrite matched fields like emails or phone numbers in results. This keeps real user details out of test runner logs and build screens.
Why do our Step Functions tests fail with rate limit errors?
Polling the cloud API too fast from many parallel tests triggers rate limits. Increase the wait time between status checks and limit how many tests run at once.
Related guides
In this post