While the Keystone CLI primarily handles local test execution and recording tunnels, test management is primarily done through Keystone Studio. However, the CLI provides useful capabilities for working with tests in your development workflow.
# Execute a specific test locally# (Tests are managed in Keystone Studio, executed via CLI runner)# Start runner to receive test execution commandskeystone start --proxy --api-key your-api-key# Tests are triggered from Studio and executed locally# Full visibility into test execution# Real-time debugging and inspection
# 1. Start your development environmentnpm run dev# 2. Start Keystone runnerkeystone start --proxy --debug# 3. From Keystone Studio:# - Select tests to run against localhost# - Execute tests with full local visibility# - Debug failures with local browser tools# - Iterate quickly on test fixes
The CLI can provision test files for local development:
Copy
Ask AI
# Set test files directoryexport TEST_FILES_DIR="./tests"# Runner provisions test files from cloud# Files are synced automatically during execution# Local files are used for debugging and inspection
# Feature branch workflowgit checkout -b feature/user-profiles# Record tests specific to this featurekeystone start --proxy# Record in Studio against localhost# Tests are saved with branch context# Can be re-run when feature is deployed# Helps validate feature before merge
# Start runner with maximum debuggingkeystone start --proxy --debug --headed# Benefits of local execution:# - Real browser with dev tools# - Console access and debugging# - Network tab inspection # - Step-by-step execution visibility# - Local file system access
# .git/hooks/pre-commit#!/bin/bash# Run critical tests before commitkeystone start --proxy --headless &RUNNER_PID=$!# Wait for runner to startsleep 5# Trigger critical tests via API# (Implementation depends on your setup)# Clean upkill $RUNNER_PID
# Validate tests locally before CIexport KEYSTONE_HEADLESS=trueexport KEYSTONE_DEBUG=falsekeystone start --proxy --headless# Run same tests that will run in CI# Ensure they pass locally first# Debug any issues before pushing
# Set up consistent test datanpm run db:seed:test# Record tests against known datakeystone start --proxy# Tests become reproducible and reliable# Data state is consistent across runs
# Reset data between test runs# Ensures clean state for each test# Prevents test interdependencies# Example cleanup scriptcleanup_test_data() { npm run db:reset:test npm run db:seed:test}