Overview
Snippets are reusable test sequences you create once and use across multiple test cases. They follow the DRY (Don’t Repeat Yourself) principle, eliminating duplication and ensuring consistent test execution. When you update a snippet, all tests using it automatically get the update. Snippets can contain any combination of steps, including other snippets, allowing you to build complex, modular test architectures. You can pass parameters to snippets to customize their behavior while maintaining the same core flow.Creating Snippets
From the Snippets Page
- Navigate to Snippets from the main menu
- Click Create to open the snippet editor
- Build your snippet steps just like a regular test case
- Optionally define parameters that can be passed when using the snippet
- Save your snippet with a descriptive title
From Existing Test Steps
You can convert existing test steps into a snippet:- Select the steps you want to convert in the test editor
- Use the “Create Snippet” action from the context menu
- The selected steps will be copied to a new snippet form
- Add a title and save
Snippet Nesting
Snippets can contain other snippets, creating nested structures up to 5 levels deep. This lets you build complex test flows from smaller, reusable components.Nesting Examples
Simple nesting (2 levels):Understanding Nesting Depth
The nesting depth is calculated from the root test case:- Root test case = depth 0
- First-level snippet = depth 1
- Snippet within a snippet = depth 2
- And so on, up to depth 5
- Current maximum depth in your test case
- Depth of the snippet you’re adding
- Whether adding it would exceed the 5-level limit
Best Practices for Nesting
- Keep nesting shallow: Prefer 2-3 levels when possible for easier debugging
- Use clear naming: Name snippets to indicate their purpose and level
- Avoid circular references: Snippets can’t reference themselves directly or indirectly
- Test independently: Ensure nested snippets work correctly on their own
- Document hierarchy: Keep track of snippet dependencies in your organization
Parameters
Parameters let you customize snippet behavior without changing the snippet itself. Define parameters when creating a snippet, then pass values when using it.Parameter Types
Snippets support these parameter types:- String: Text values for form fields, URLs, selectors
- Number: Numeric values for timeouts, quantities, indices
- Boolean: Toggle values for flags and options
- Object: Complex data structures (stored as JSON)
- Array: Lists of values (stored as JSON)
Defining Parameters
When creating or editing a snippet:- Open the Parameter Definitions section
- Click Add Parameter
- Configure each parameter:
- Name: Unique identifier (used in expressions)
- Type: Choose from the supported types
- Required: Whether the parameter must be provided
- Default Value: Value used if not provided
- Description: Helpful text explaining the parameter’s purpose
Using Parameters in Snippets
Reference parameters in step values using expressions:Parameters are resolved at runtime, allowing you to use the same snippet with different values. Parameter names are case-sensitive, so ensure you use the exact name defined in the snippet’s parameter definitions.
Passing Parameters
When adding a snippet to a test:- Select the snippet
- If the snippet has parameters, you’ll see a parameter form
- Enter values for each parameter
- Required parameters are marked with an asterisk
Best Practices
Snippet Design
Single purpose: Each snippet should do one thing well. Create focused snippets like “Login as Admin” or “Search Products” rather than mega-snippets that do everything. Self-contained: Snippets should work independently. Avoid dependencies on external state or previous steps that might not exist when the snippet runs. Clear naming: Use descriptive titles that indicate purpose and context. Examples:- ✅ “Login as Admin”
- ✅ “Add Item to Cart”
- ❌ “Snippet 1”
- ❌ “Test Flow”
When to Create Snippets
Create snippets for:- Actions repeated across 3+ tests
- Complex sequences that are error-prone to recreate
- Team-shared patterns everyone should use consistently
- Setup/teardown that must be identical across tests
- Workflows that change frequently (update once, everywhere gets the change)
- One-off sequences used in a single test
- Steps that change too frequently (wait until they stabilize)
- Overly complex mega-snippets that do too much
- Simple, single-step actions (just use the step directly)
Parameter Strategy
Identify what varies: Focus parameters on values that change between uses, not on everything. Keep defaults useful: Default values should work for common scenarios without requiring overrides. Document parameters: Use clear descriptions so users understand what each parameter does and when to override it. Test both modes: Validate snippets work with default parameters and with overrides.Nesting Strategy
Limit depth: Prefer shallow nesting (2-3 levels) for easier debugging and maintenance. Layer responsibilities: Use nesting to create logical layers:- Level 1: High-level workflows (e.g., “Complete Purchase”)
- Level 2: Mid-level actions (e.g., “Add to Cart”)
- Level 3: Low-level interactions (e.g., “Click Button”)
Maintenance
Regular review: Periodically review snippets to ensure selectors and logic are still valid. Update, don’t duplicate: When UI changes, update existing snippets rather than creating new ones. Deprecate unused snippets: Remove or mark snippets that are no longer needed. Test independently: Run snippets on their own before using them in tests to catch issues early. Version awareness: When updating snippets, consider impact on existing tests that use them.Debugging Snippets
Common Issues
Snippet not appearing in dropdown Symptom: Can’t find your snippet when adding an Add Snippet step Solutions:- Verify the snippet exists in your workspace (check the Snippets page)
- Ensure the snippet contains valid steps
- Refresh the test editor to reload available snippets
- Check that you have access permissions if using team snippets
If you just created a snippet, it may take a moment to appear in the dropdown. Try refreshing the test editor if the snippet doesn’t show up immediately.
- Test the snippet independently to isolate the failure
- Check if selectors in the snippet are outdated
- Verify environment variables the snippet uses are defined
- Ensure page state is correct before the snippet runs
- Check browser console for JavaScript errors
- Review the trace view to see exactly where it fails
- Verify you’ve set parameter values in the parameter form
- Check that parameter names match exactly (case-sensitive)
- Ensure parameter types match (string vs number vs boolean)
- Test the snippet without parameters first to confirm base functionality
- Review snippet parameter definitions to ensure they’re configured correctly
- Refresh your test editor to reload snippet changes
- Clear browser cache if changes still don’t appear
- Wait a moment for cache updates to propagate
- Verify you saved the snippet changes
- Check if other browser tabs have the editor open with stale data
- Simplify your snippet structure by reducing nesting levels
- Break complex nested snippets into separate, parallel snippets
- Review your snippet hierarchy to find opportunities to flatten
- Consider if some nesting can be moved to the test case level
- Review snippet dependencies to find the circular path
- Remove the circular reference by restructuring snippets
- Create a new snippet that doesn’t reference the problematic chain
Debugging Techniques
Use the trace view: When a snippet fails, use the trace view to see exactly which step failed and why. The trace shows the full execution path including nested snippets.The trace view shows the complete execution path including all nested snippets, making it easy to see where failures occur in complex nested structures.
Real-World Examples
Login Flow Snippet
Purpose: Reusable login sequence used across multiple tests Steps:- Navigate to
/login - Fill email:
{{TEST_USER_EMAIL}} - Fill password:
{{TEST_USER_PASSWORD}} - Click submit button
- Wait for dashboard
- Verify URL contains
/dashboard
Parameterized Search Snippet
Purpose: Search functionality with customizable query Parameters:searchQuery(string, required): What to search forwaitForResults(boolean, default: true): Whether to wait for results
- Fill search field:
{{snippet.params.searchQuery}} - Press Enter
- If
{{snippet.params.waitForResults}}, wait for results to appear
Nested Checkout Flow
Structure:Related Documentation
- Add Snippet Step - How to add snippets to your tests
- Expressions - Using expressions in snippet parameters
- Test Cases - Creating and managing test cases
- Editor - Building tests in the visual editor

