Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Run Tests

Now that you’ve written your first RocketQA test, it’s time to execute it and understand the results. This guide covers everything you need to know about running tests effectively.

The simplest way to run your tests is to execute all feature files:

Terminal window
# Run all tests in the features directory
npx rocketqa test

This command will:

  • Discover all .feature files in the features/ directory
  • Execute each scenario sequentially
  • Generate detailed reports
  • Display results in the console

You can target specific tests in several ways:

Terminal window
# Run a specific feature file
npx rocketqa test features/authentication.feature
# Run tests matching a name pattern
npx rocketqa test --name "login"
# Run tests matching a regex pattern
npx rocketqa test --grep "user|auth"
# Run multiple specific files
npx rocketqa test features/login.feature features/checkout.feature

Tags provide powerful filtering capabilities for your test execution:

Terminal window
# Run tests with specific tags
npx rocketqa test --tags @smoke
# Run tests with multiple tags (AND logic)
npx rocketqa test --tags "@smoke and @critical"
# Run tests with any of multiple tags (OR logic)
npx rocketqa test --tags "@smoke or @regression"
# Exclude tests with specific tags
npx rocketqa test --tags "not @slow"
# Complex tag expressions
npx rocketqa test --tags "(@smoke or @critical) and not @flaky"
Feature: E-commerce Checkout
@smoke @critical
Scenario: Guest user can complete basic purchase
Given navigate to "https://shop.com/products"
When add item to cart and proceed to checkout
Then order confirmation is displayed
@regression @payment
Scenario: User can pay with multiple payment methods
Given logged in user has items in cart
When complete checkout with credit card
Then payment is processed successfully
@slow @integration
Scenario: Order integrates with inventory system
Given product has limited stock
When user purchases last available item
Then inventory is updated correctly

By default, RocketQA runs tests in headless mode - browsers run in the background without a visible window:

Terminal window
# Runs in headless mode
npx rocketqa test

Advantages:

  • ✅ Faster execution
  • ✅ Lower resource usage
  • ✅ Perfect for CI/CD environments
  • ✅ No interference from desktop interactions

For debugging or demonstration purposes, run with visible browsers:

Terminal window
# Run with visible browser
npx rocketqa test --no-headless
**Use cases:**
- 🔍 Debugging test failures
- 👀 Demonstrating test automation
- 📹 Recording test execution videos
- 🐛 Investigating timing issues
### Keep Browser Open
Prevent the browser from closing after test completion:
```bash
# Keep browser open for inspection
npx rocketqa test --no-headless --keep
## Understanding Test Output
### Console Output
RocketQA provides detailed console output during test execution:

🚀 Running cucumber tests… Command: node node_modules/@cucumber/cucumber/bin/cucumber-js features//*.feature -c cucumber.mjs —exit 📁 Package root: /usr/local/lib/node_modules/rocketqa 📁 Current working directory: /Users/alex/my-project 📁 Feature path: /Users/alex/my-project/features//*.feature 🥒 Using cucumber-js at: /usr/local/lib/node_modules/rocketqa/node_modules/@cucumber/cucumber/bin/cucumber-js

Feature: User Authentication

Scenario: Successful login with valid credentials ✓ Given navigate to “https://your-app.com” ✓ When click $homepage.loginLink ✓ And type “john.doe@example.com” into $loginPage.usernameField ✓ And type “SecurePassword123!” into $loginPage.passwordField ✓ And click $loginPage.loginButton ✓ Then $dashboard.welcomeMessage is visible ✓ And $dashboard.userProfile is visible ✓ And page title contains “Dashboard”

1 scenario (1 passed) 8 steps (8 passed) 0m03.247s

### Exit Codes
RocketQA uses standard exit codes:
- **0**: All tests passed
- **1**: One or more tests failed
- **2**: Configuration or setup error
## Environment Configuration
### Setting Base URL
Configure a base URL for your application which is opend by default
```bash
# Set website URL for all tests
npx rocketqa test --website-url=https://staging.your-app.com
Then use relative URLs in your tests:
```gherkin
Scenario: Navigate to login page
Given navigate to "/login" # Uses WEBSITE_URL + /login
When type credentials and submit
Then user is logged in
Error: locator.click: Timeout 30000ms exceeded.
Element $loginPage.submitButton was not found

Solutions:

  1. Verify locator in locators.yml
  2. Check if element exists on the page
  3. Wait for dynamic content to load
  4. Use browser dev tools to verify selector
Error: Expected text "Welcome" but found ""

Solutions:

  1. Add explicit waits:
When wait for $dashboard.welcomeMessage to be visible
Then $dashboard.welcomeMessage contains text "Welcome"
  1. Increase timeout in step definitions
  2. Use visible browser mode to observe timing
Error: net::ERR_CONNECTION_REFUSED

Solutions:

  1. Verify the URL is correct and accessible
  2. Ensure the application server is running
  3. Check network connectivity
  4. Validate SSL certificates for HTTPS sites

🎉 Congratulations! You’ve completed the RocketQA getting started guide. You’re now ready to build comprehensive test suites for your web applications using natural language!

👉 Next, proceed to check your test reports to review your results and gain insights into your test runs.