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.
Basic Test Execution
Section titled “Basic Test Execution”Running All Tests
Section titled “Running All Tests”The simplest way to run your tests is to execute all feature files:
# Run all tests in the features directorynpx rocketqa test
This command will:
- Discover all
.feature
files in thefeatures/
directory - Execute each scenario sequentially
- Generate detailed reports
- Display results in the console
Running Specific Tests
Section titled “Running Specific Tests”You can target specific tests in several ways:
# Run a specific feature filenpx rocketqa test features/authentication.feature
# Run tests matching a name patternnpx rocketqa test --name "login"
# Run tests matching a regex patternnpx rocketqa test --grep "user|auth"
# Run multiple specific filesnpx rocketqa test features/login.feature features/checkout.feature
Using Tags for Test Organization
Section titled “Using Tags for Test Organization”Tags provide powerful filtering capabilities for your test execution:
Running Tagged Tests
Section titled “Running Tagged Tests”# Run tests with specific tagsnpx 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 tagsnpx rocketqa test --tags "not @slow"
# Complex tag expressionsnpx rocketqa test --tags "(@smoke or @critical) and not @flaky"
Example Tagged Feature
Section titled “Example Tagged Feature”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
Execution Modes
Section titled “Execution Modes”Headless Mode (Default)
Section titled “Headless Mode (Default)”By default, RocketQA runs tests in headless mode - browsers run in the background without a visible window:
# Runs in headless modenpx rocketqa test
Advantages:
- ✅ Faster execution
- ✅ Lower resource usage
- ✅ Perfect for CI/CD environments
- ✅ No interference from desktop interactions
Headed Mode (Visible Browser)
Section titled “Headed Mode (Visible Browser)”For debugging or demonstration purposes, run with visible browsers:
# Run with visible browsernpx 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 inspectionnpx 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 testsnpx rocketqa test --website-url=https://staging.your-app.com
Then use relative URLs in your tests:```gherkinScenario: Navigate to login page Given navigate to "/login" # Uses WEBSITE_URL + /login When type credentials and submit Then user is logged in
Debugging Test Failures
Section titled “Debugging Test Failures”Common Failure Scenarios
Section titled “Common Failure Scenarios”Element Not Found
Section titled “Element Not Found”Error: locator.click: Timeout 30000ms exceeded.Element $loginPage.submitButton was not found
Solutions:
- Verify locator in
locators.yml
- Check if element exists on the page
- Wait for dynamic content to load
- Use browser dev tools to verify selector
Timing Issues
Section titled “Timing Issues”Error: Expected text "Welcome" but found ""
Solutions:
- Add explicit waits:
When wait for $dashboard.welcomeMessage to be visibleThen $dashboard.welcomeMessage contains text "Welcome"
- Increase timeout in step definitions
- Use visible browser mode to observe timing
Navigation Problems
Section titled “Navigation Problems”Error: net::ERR_CONNECTION_REFUSED
Solutions:
- Verify the URL is correct and accessible
- Ensure the application server is running
- Check network connectivity
- 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.