HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Testing

This topic describes unit testing, local testing, and how to install into test accounts in Optimizely Connect Platform (OCP).

Unit Testing

The app templates include a configuration for Jest but you can use any unit testing framework. Just make sure it is configured to run via yarn test. Unit tests are run automatically before uploads and when building your app to run on OCP infrastructure. If any tests fail, your app cannot be published. Coverage minimums are strongly recommended.

See the basic template (generated from zaius app init) for examples on how to use unit tests to cover difficult tasks such as a state-machine-based job.

Local Testing

In addition to unit tests, you can also start your app up locally in a simulated environment in order to verify your implementation. To start your app via the CLI, run zaius app start-dev from your app's root directory. You will be asked to add a local runtime to your package the first time, then your app will start up, simulate an install, and print out the URLs you can use to interact with your app.

$ zaius app start-dev
Building the app...
App started successfully
App logs will be piped to mailchimp-sync/logs/dev.log
App listening on port 3010
[info] Performing Install
App installed successfully
---Function Endpoints---
http://localhost:3010/functions/mailchimp_sync/get_lists/a5154fa1-4b10-5e3a-9b37-fc3f46087519
http://localhost:3010/functions/mailchimp_sync/get_zaius_fields/4447da44-06c3-502a-b447-0e49533c85d6

When running your app locally, your app may write to any of the stores (secret, settings, or key-value). The data will be persisted to disk in a .dev folder under your app so that you can restart your app and test where you left off. If you ever wish to start fresh, clear this folder to delete your stores before starting the app.

The local runtime does not yet provide all the functionality of the OCP platform but will allow you to test your running code before uploading and publishing your app.

Install into Test Accounts

To ease development and testing, apps can be installed into an account from the CLI even when they are not visible on the App Store (for example, development and beta versions).

Use pre-release tags such as -dev or -beta to publish a new version of an app without making it public or automatically upgrading existing installations.

Pre-release apps will not show up in the App Directory but can be accessed directly by you. Go to https://get.zaius.app/<app_id>/<version> to access a specific version, for example, https://get.zaius.app/my_app/0.0.0-dev. From here you can install the app into your test account. Once installed, the app is visible in your installed apps and can be uninstalled from the UI as well.

Manual Install

Pre-release apps can also be installed manually from the CLI. To manually install a pre-release app into an account:

zaius directory install [email protected] <tracker_id>

Where <tracker_id> is the Tracker ID of the account to which you wish to install. When this command completes, your app will be installed and ready to go.
You can verify the app is installed with:

zaius directory list-installs [email protected]

Manual Uninstall

To manually uninstall an app from an account using the CLI:

zaius directory uninstall [email protected] <tracker_id>

Did this page help you?