Testing Overview
Testing pieces ensures they work correctly before contributing them to the community. Activepieces provides multiple ways to test:Local Testing
Test in development environment
Unit Tests
Automated test suites
Integration Tests
End-to-end testing
Local Testing with Hot Reload
The fastest way to test during development is using hot reload.1
Start Development Server
- Frontend on
http://localhost:4200 - Backend on
http://localhost:3000 - Engine for flow execution
2
Open Activepieces
Navigate to
http://localhost:4200 in your browser3
Create a Test Flow
- Click “Create Flow”
- Add your piece as a trigger or action
- Configure the properties
- Click “Test” to execute
4
Make Changes
Edit your piece code - changes are reflected immediately without restart!Save and test again - no rebuild needed.
Testing Actions
Manual Testing
Test actions directly in the flow builder:Test Function
Provide atest function that uses safe test data:
Testing Triggers
Polling Triggers
Polling triggers can be tested by clicking the “Test” button:Webhook Triggers
Test webhook triggers by:- Enable the trigger in a flow
- Trigger the actual event in the external service
- Verify webhook was called and flow executed
For webhook testing, you’ll need to use a tool like ngrok or deploy to a public URL to receive webhooks during development.
Unit Tests
Write automated tests using Vitest:Test File Structure
Example: Action Test
send-message.test.ts
Example: Trigger Test
new-message.test.ts
Running Tests
Integration Tests
End-to-end tests that run actual flows:e2e/my-piece.spec.ts
Testing Best Practices
Test Error Cases
Test Error Cases
Don’t just test the happy path:
Mock External APIs
Mock External APIs
Never make real API calls in tests:
Use Sample Data
Use Sample Data
Provide realistic sample data for testing:
Test State Management
Test State Management
For triggers, test state storage:
Debugging
Console Logging
Use console.log during development:VS Code Debugger
Set breakpoints and debug:- Add launch configuration:
.vscode/launch.json
- Set breakpoints in your code
- Press F5 to start debugging
Network Debugging
Inspect HTTP requests:Testing Checklist
Before contributing your piece:- All actions work correctly with valid inputs
- Error messages are clear and helpful
- Authentication works and validates properly
- Dropdowns load options correctly
- Dynamic properties refresh as expected
- Triggers receive and process events
- Webhook registration/cleanup works
- Unit tests pass
- No console errors or warnings
- Sample data is realistic
- Documentation is complete
Next Steps
Contribute Your Piece
Submit your piece to the community
Versioning
Learn about piece versioning