Advanced Expressions for Test Data
Date Formatting
Instead of manually entering static dates or relying solely on faker.js
, you can use natural language expressions inside the {{date:...}}
syntax to populate date fields. These dynamic dates work seamlessly in input steps, form validations, naming, and API payloads.
Why Use Dynamic Dates?
- Automate date-dependent test scenarios
- Avoid hardcoding dates that expire
- Adjust dates relative to test execution time (for example, “today + 2 days”)
- Handle business-specific logic such as “last working day of the month”
Common Queries (Supported Commands)
Purpose | Expression | Example Output |
---|---|---|
Current Date | {{date:today>>dd}} | 28 |
Current Month | {{date:today>>mm}} | 05 |
Current Year | {{date:today>>yyyy}} | 2025 |
Today | {{date:today}} | 2025-05-28 |
Tomorrow | {{date:tomorrow}} | 2025-05-29 |
Yesterday | {{date:yesterday}} | 2025-05-27 |
First Working Day of Last Week | {{date:first working day of last week}} | 2025-05-20 |
Two Days from Now | {{date:today +D days}} | 2025-05-30 |
Previous Month | {{date:today -d month>>mm}} | 04 |
Previous Year | {{date:today -d year>>yyyy}} | 2024 |
Next Month | {{date:today +d month>>mm}} | 06 |
Next Year | {{date:today +d year>>yyyy}} | 2026 |
Concatenation Expressions
You can dynamically combine values using string and number concatenation. This is useful when you need to build inputs like email addresses, usernames, numeric values, or test-specific IDs.
Number + Number
Add numbers directly, or combine numeric values from test data with constants.
String + Faker
Combine static strings with dynamically generated faker values using the ${}
syntax.
${'test_' + {{internet.userName()}}}
Custom JavaScript Evaluation
For complex formatting or calculations that go beyond simple expressions, you can use JavaScript code blocks directly within your test data.
Example: Perform custom calculations
Use case: Add tax (18%) to a base price stored in test data {{base_price}}
.