Test Flows
Overview of Test Flows
The “Test Flow” feature in Sparrow is designed to enable users to build and manage comprehensive test sequences for API behavior validation within their projects. This functionality is crucial for verifying API performance under various conditions and scenarios.
Different Ways to Add Test Flows
There are several methods to add a Test Flow connection in your application. Below are the primary approaches:
1. From Main Screen
Users can easily add a Test Flow connection directly from the main screen of the application. This method provides a straightforward interface, allowing for quick setup without navigating through multiple menus.
2. From the Left-Panel Section
Users can also add a Test Flow from the left panel for quick access.
Steps:
- Open the application.
- Click the "+" button present on the left side of the panel.
- Select the "Add Test Flow" option from the dropdown.
3. From the Test Flows Section
Users can also add a Test Flow from the Test Flows section.
Steps:
- Open the application.
- Click the "Test Flow" option present on the left side of the panel.
- Click on the "+ Add New Flow" option.
Default Test Flow Interface
When the user clicks on "Add Flow," they will be directed to the Test Flow home page. This page includes several key elements:
- Flow Name: A field to enter the name of the test flow.
- Save and History Buttons: Options to save the current flow and view the history of previously created flows.
- Start Button: This button initiates the test flow execution.
- Add Block Button: Users can click this to add new blocks, allowing for the inclusion of multiple steps or scenarios within the test flow.
How to Create a Test Flow
- Open the Sparrow Application: Launch the Sparrow application on your device.
- Click on "+ Test Flow": On the main menu, select the "+ Add Test Flow" option.
- Add a Block: Click on the Add Block button to open a new block for adding APIs.
- Select REST API: You can either drag and drop the REST API from the left panel or choose the required REST API from the dropdown menu in the block (Collection-Folder-REST API).
- Proceed to the Next Step: Click the Next button to continue adding the selected REST API to the flow.
- Add API to the Flow: Complete the process by adding the selected REST API into the test flow.
How to Edit or Delete API Blocks
Users have the capability to edit or delete API blocks within the test flow. Editing allows users to modify existing APIs to better fit their testing needs. If a block is no longer required or relevant, users can easily delete it, ensuring that the test flow remains organized and focused. This functionality enhances the flexibility and efficiency of managing test flows.
Edit/Change the API Present in the Block
To edit or change the API present in a block, follow these steps:
- Click on the API: Select the API present in the block that you wish to change.
- Select New API Location: Choose the location of the new API by selecting the appropriate collection and folder.
- View Updated API: The newly updated API will appear in that block, reflecting your changes.
Delete the Block
To delete a block, follow these steps:
- Click on the Three Horizontal Dots: Select the three horizontal dots present on the block that you want to delete.
- Choose the Delete Option: Click on the Delete option from the menu.
- Confirm Deletion: A delete pop-up will appear. Click on Delete to confirm your action.
- Impact on Subsequent Blocks: If there are blocks following the deleted block, then those blocks will be connected to previous available block automatically.
How to Execute Created Test Flows
To execute the created test flow, you can use one of the following options:
- Use the Run Button: After adding blocks to the flow, a Run button will appear in the user interface. Click on this Run button to execute the specific block within the flow.
When you run the test flow, each block will execute sequentially. If the API call in a block is successful, that block will be highlighted in green, indicating a successful execution. Conversely, if the API call fails, the block will turn red, signaling an error in the execution. This color-coding helps users quickly identify the status of each step in the test flow.
Upon completion of the Test Flow execution, a toast message will be displayed, indicating the number of tests that passed and the number that failed.
How to Analyze Test Flows Results
Execution Time and Status Code
After the execution of each block, users will receive detailed information about the status code of the API call and the execution time measured in milliseconds. This data helps users assess the performance and reliability of each API request within the test flow.
Detailed Execution History
After execution, if you want to see the detailed response of a specific block, simply click on that block. This action will display the request and response details, allowing you to review the results. You will also be able to perform various operations similar to those available in a REST API tool, enhancing your ability to analyze and troubleshoot the API interactions.
How to View the Test Flows History
To view the previous execution history, simply click on the See History button located in the top right corner. The history will then open below, displaying all previous execution details.
How to Save the Test Flows
To save the test flow, click on the Save button located in the top right corner. A success toast message will appear once the test flow is saved, confirming the action. You will then be able to see the saved flow in the left-hand side panel under Test Flows.
Dynamic Expressions in Sparrow
Dynamic expressions in Sparrow allow you to seamlessly chain multiple API requests by referencing and extracting data from previous API responses. This is especially useful when working with multi-step workflows where one request’s output becomes another request’s input.
Where You Can Use Dynamic Expressions
Dynamic expressions can be inserted into nearly any part of your API request:
URL, Query Parameters, Headers, Body, and Auth.
These expressions dynamically pull values from previously executed API blocks, making your requests context-aware and reducing manual effort.
Getting Started with Dynamic Expressions
Step 1: Locate and Click the fx
Button
- In any editable field (URL, headers, body, etc.), click on the fx icon.
- This opens the Insert Dynamic Content Modal, where you can craft expressions or insert dynamic values from previous responses.
Step 2: Expression Editor
The Expression Editor allows you to use JavaScript-like syntax to build complex dynamic values.
Example:
$$ Block_1.response.body.data.accessToken.token + " - Updated"
This example extracts the accessToken
field from the response of Block 1, then appends " - Updated"
to it.
You can use string manipulation, math operations, conditionals, and more in this editor.
Step 3: Insert Dynamic Content
Within the Dynamic Content tab of the modal:
- Navigate through your previous API blocks.
- Select a specific field to inject into the current request.
This inserts placeholders like: $$Block_1.response.body.data.accessToken.token
You can also use:
- Environment Variables for dynamic configurations.
- Global Variables shared across all flows.
Step 4: Use Built-in Functions
The Functions tab includes useful helpers to manipulate strings, numbers, and other types of data.
| Function | Description Example
| toUpperCase()
| Converts string to uppercase | toUpperCase("hello")
→ "HELLO"
|
| trim()
| Removes leading/trailing whitespace | trim(" test ")
→ "test"
|
| parseInt()
| Converts a string to integer | parseInt("42")
→ 42
|
| Math.random()
| Returns a float between 0 and 1 | Math.floor(Math.random() * 10)
Combined Example:
$$Block_1.response.body.data.accessToken.token.toUpperCase()
This convert the Block 1 access token to uppercase.
Step 5: Run Preview
Before inserting the expression:
- Click the Run Preview button.
- This lets you evaluate the result of your expression in real-time.
- Confirm correctness and ensure no runtime errors or undefined values.
Step 6: Insert into Request
Once you're satisfied with the preview output:
- Click Insert Dynamic Content
- The resolved or placeholder expression will be inserted into the appropriate field (body, URL, header, etc.)
Running the Complete Flow
Once all blocks are set up and connected:
Click the “Run” Button
- Executes each block sequentially.
- Resolves all dynamic content and expressions on the fly.
- Passes relevant output data between the blocks.
This is especially helpful for:
- Authentication + usage (login → token → use token)
- Create + update + fetch workflows
- Pagination and search flows
Best Practices & Tips
- Use clear block names for readability in expressions.
- Test each block independently before chaining.
- Use Run Preview to catch logic issues early.
- Validate all referenced fields actually exist in the response.
- Use
||
fallback operators in case values are undefined.
Example with fallback:
$$Block_3.response.body.email || "default@example.com"
Conclusion
Dynamic expressions in Sparrow empower you to build flexible, maintainable, and data-driven workflows across your API test collections.
By combining previous responses, helper functions, and expression evaluation, you can eliminate hardcoding and automate your entire flow.