Skip to main content

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

FeatureDescription
Custom input dataDefine JSON test data
Method selectionChoose HTTP method (for invocable functions)
Query parametersAdd query string parameters
User impersonationTest as different users
Real-time executionSee results immediately
Log viewingView console output
Saved test inputsSave and reuse test scenarios

Running a Test

  1. Open your function in the Developer Portal
  2. Click Test or open the test panel
  3. Configure your test input:
    • Enter JSON data in the Body field
    • Add query parameters if needed
    • Select HTTP method (invocable functions)
  4. Click Run
  5. 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:

ParameterValue
page1
limit10
filteractive

HTTP Method

For invocable functions, select the method to test:

  • GET
  • POST
  • PUT
  • DELETE

User Impersonation

Test how your function behaves for different users:

OptionDescription
UnauthenticatedTest as anonymous user
Specific UserSelect a user from your API
Service AccountTest with service account credentials

Testing Permissions

OptionDescription
Skip Security PolicyBypass row-level access control
Skip RolesIgnore 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

  1. Configure your test (body, query params, method)
  2. Click Save Test Input
  3. Enter a descriptive name (e.g., "Valid order with 3 items")
  4. Click Save

Managing Saved Inputs

ActionDescription
LoadApply saved input to current test
UpdateUpdate saved input with current values
RenameChange the saved input name
DeleteRemove 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:

  1. Test with minimal valid input
  2. Test with complete valid input
  3. Test with invalid input
  4. Test edge cases

Integration Testing

Test functions that interact with data:

  1. Create test data in collections
  2. Run function
  3. Verify data changes
  4. Clean up test data

Regression Testing

Use saved test inputs to catch regressions:

  1. Create comprehensive saved inputs during development
  2. Run all saved inputs after changes
  3. 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

  1. First test with Skip Security Policy and Skip Roles enabled
  2. Verify the function logic works
  3. Then test with actual permissions
  4. 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