Local testing
Use the OCP local testing tool to develop and test your Optimizely Connect Platform (OCP) applications locally before publishing.
The OCP local testing tool provides a complete local development environment for building, testing, and debugging your OCP applications before publishing them to Optimizely Connect Platform (OCP).
BetaThe OCP local testing tool is currently in beta. Functionalities are subject to change. If you have any feedback, visit
ocp-developer-feedback.
You can get the following benefits by using the OCP local testing tool:
- Faster development – Test changes instantly without deploying to the cloud.
- Full settings form support – Preview and test your app's settings form as it displays in the OCP App Directory, including validation, conditional fields, and dynamic data sources.
- Real-time reloading – Automatically detect and rebuild codes changes.
- Interactive testing – Test functions, jobs, and lifecycle hooks through a web interface.
- Detailed logging – View comprehensive logs for debugging.
Prerequisites
- Access to OCP app.
- A working OCP CLI installation.
Launch the testing tool
-
Go to your App Directory containing the following
app.yml:cd my-ocp-app -
Start the local testing tool using OCP CLI:
# Using OCP CLI ocp dev -
Access
http://localhost:3000in your browser, which automatically opens after you start the local testing tool. -
Ensure there are no automatic rebuilds. The testing tool detects file changes in your app's
src/folder and rebuilds automatically. -
Test your changes in the web UI.
-
Review logs in the console panel if issues occur.
Understand the web interface
The local testing tool provides a web-based interface with the following sections:
- App Settings – Configure and preview your app's settings form.
- Functions – Test webhook and HTTP functions with custom payloads.
- Jobs – Run jobs manually and view execution history.
- Destinations – Test data sync destination configurations.
- Sources – Test data source configurations.
- Console – View logs from your app. You can filter by source, level, and category.
- Settings – View and edit your app-stored storage.
- Secrets – View and edit your encrypted data.
- KVStore – Access your key-value data.
- Shared KVStore – Access your shared key-value data.
- Notifications – View your app notifications.
Configure the tool
Configure the environment variables
Create an .env.local file in your app directory to configure the tool:
# Server port (default: 3000)
OCP_LOCAL_PORT=3001
NoteThis is required if you want to customize default settings.
Configuration file
Create a .ocp-local/config.json file in your app directory for advanced configuration. The account configuration populates the account object in the AppContext available to your app code.
{
"account": {
"organizationId": "my-org-123",
"instanceId": "my-instance-456",
"trackerId": "my-tracker-id"
}
}
NoteYou should add the
.ocp-localfolder to your.gitignorefile to avoid accidentally commiting configuration data to your git repository.
Test your app
Test lifecycle hooks
The OCP local testing tool lets you test your app's lifecycle hooks by simulating installation and uninstallation. The lifecycle hooks are automatically called when you install or uninstall an app in the local testing tool.
Validate settings forms
The tool renders your app's settings form as it displays in OCP's App Directory. This lets you iterate on your settings UI without having to repeatedly publish to the cloud.
- Go to Settings.
- Enter your information in the Settings form fields. The form renders dynamically based on your
settings.ymlschema. - Test field validation, conditional visibility, and dynamic data sources. Settings are persisted and available to your app code.
NoteThe Settings form uses the same rendering engine as the OCP App Directory, so what you see locally matches what users will see in their OCP app directory.
Test functions
- Go to Functions.
- Select the function you want to test from the drop-down list.
- Choose the HTTP method (GET, POST, PUT, DELETE, PATCH).
- Enter a JSON payload in the request body.
- Click Send to execute.
- View the response and logs in the console panel.
Test jobs
- Go to Jobs.
- Select a job from the drop-down list.
- Click Start Job to execute.
- View execution history and job states.
- Expand State entries to see detailed information.
Publishing to OCP
After testing your app in the local testing tool, deploy your app to OCP.
NoteLocal testing simulates the OCP environment but cannot replicate all production behaviors. Test your app on a development OCP account before releasing. See Feature comparison for details on what must be tested after publishing to OCP.
Next steps
- Feature comparison – Gives a comparison between features that are supported in the local testing tool and in OCP production.
Updated about 2 hours ago