Testing Functions
The Developer Portal includes a built-in test runner for testing functions before deploying them to production.
Test Runner
Access the test runner from any function's edit page.
Features
| Feature | Description |
|---|---|
| Custom input data | Define JSON test data |
| Method selection | Choose HTTP method (for invocable functions) |
| Query parameters | Add query string parameters |
| User impersonation | Test as different users |
| Real-time execution | See results immediately |
| Log viewing | View console output |
| Saved test inputs | Save and reuse test scenarios |
Running a Test
- Open your function in the Developer Portal
- Click Test or open the test panel
- Configure your test input:
- Enter JSON data in the Body field
- Add query parameters if needed
- Select HTTP method (invocable functions)
- Click Run
- View results and logs
Test Input Configuration
Request Body
Enter JSON data that simulates the request body:
{
"orderId": "order-123",
"items": [
{ "productId": "prod-1", "quantity": 2 },
{ "productId": "prod-2", "quantity": 1 }
],
"customerId": "cust-456"
}
Query Parameters
Add query parameters for invocable function tests:
| Parameter | Value |
|---|---|
page | 1 |
limit | 10 |
filter | active |
HTTP Method
For invocable functions, select the method to test:
- GET
- POST
- PUT
- DELETE
User Impersonation
Test how your function behaves for different users:
| Option | Description |
|---|---|
| Unauthenticated | Test as anonymous user |
| Specific User | Select a user from your API |
| Service Account | Test with service account credentials |
Testing Permissions
| Option | Description |
|---|---|
| Skip Security Policy | Bypass row-level access control |
| Skip Roles | Ignore role-based permissions |
Use these to test function logic separately from access control.
Viewing Results
Output
The function's return value appears in the Output section:
{
"success": true,
"processedItems": 3,
"total": 149.97
}
Logs
Console output appears in the Logs section:
[INFO] 0ms - Processing order: order-123
[INFO] 15ms - Found 3 items
[INFO] 45ms - Calculated total: 149.97
[WARN] 46ms - Customer has pending balance
Each log entry shows:
- Severity level (INFO, WARN, ERROR)
- Milliseconds from execution start
- Message
Errors
If the function throws an error:
{
"error": "Invalid order: no items provided",
"halted": true
}
Execution Time
View total execution time in milliseconds to identify performance issues.
Saved Test Inputs
Save test configurations for reuse and regression testing.
Saving a Test Input
- Configure your test (body, query params, method)
- Click Save Test Input
- Enter a descriptive name (e.g., "Valid order with 3 items")
- Click Save
Managing Saved Inputs
| Action | Description |
|---|---|
| Load | Apply saved input to current test |
| Update | Update saved input with current values |
| Rename | Change the saved input name |
| Delete | Remove saved input |
Best Practices for Saved Inputs
Create saved inputs for:
- Happy path — Valid data that should succeed
- Edge cases — Boundary conditions (empty arrays, max values)
- Error cases — Invalid data that should fail gracefully
- Permission scenarios — Different user roles
Testing Strategies
Unit Testing Approach
Test individual functions in isolation:
- Test with minimal valid input
- Test with complete valid input
- Test with invalid input
- Test edge cases
Integration Testing
Test functions that interact with data:
- Create test data in collections
- Run function
- Verify data changes
- Clean up test data
Regression Testing
Use saved test inputs to catch regressions:
- Create comprehensive saved inputs during development
- Run all saved inputs after changes
- Verify outputs match expectations
Debugging Tips
Add Logging
Insert console.log statements to trace execution:
console.log('Input received:', JSON.stringify(body));
console.log('Processing item:', item.id);
console.log('Calculated result:', result);
Check Variable Values
Log intermediate values to find issues:
const filtered = items.filter(i => i.active);
console.log('Filtered items count:', filtered.length);
const total = filtered.reduce((sum, i) => sum + i.price, 0);
console.log('Total before tax:', total);
Isolate Problems
Test components separately:
// Test external API call alone
const response = await fetch(externalUrl);
console.log('External API status:', response.status);
console.log('External API response:', await response.text());
Test Permissions Separately
- First test with Skip Security Policy and Skip Roles enabled
- Verify the function logic works
- Then test with actual permissions
- Fix any access control issues
Common Issues
Function Times Out
- Check for infinite loops
- Reduce external API calls
- Use parallel requests where possible
- Increase timeout limit if needed
Unexpected Results
- Log intermediate values
- Check input data format
- Verify external API responses
- Check for async/await issues
Permission Denied
- Test with Skip Security Policy/Roles first
- Verify service account permissions
- Check role assignments
- Review security policy paths