Testing worklets

Test your worklets

When I write code, it works perfectly the first time, every time ... said no one ever. To test and debug your worklets, click the "Testing" tab in the bottom navigation menu.

Select the worklet you want to test from the dropdown. If you want to run just a single block, select it in the next dropdown. Selecting "Start" will run the full worklet.

This two-paned tab accepts an input in the left pane and prints worklet output and logs in the right pane. When you're ready, click the "Run" button to run the worklet or block.

Input

Your input must be JSON-serializable.

Example valid inputs:

  • "this is a string"

  • 12345

  • [1, 2, 3, 4]

  • {"this is": "JSON"}

Example invalid inputs:

  • these are random words but not a string

  • 1, 2, 3, 4, 5

  • 1 + 2

  • {"this is": "would be fine except", "the JSON is invalid"; "because semicolon"}

Calling this "input," not "inputs," is intentional. Worklets assume you only give one input, and the function signatures for code blocks use positional arguments. If you need multiple variables passed into a function, that's what the JSON is for; create a dictionary with as many keys as necessary.

Output logging

While debugging a Code or Decision block, it might be handy to log some information. You can use Python's print() statements.

Worklet run logs

Every time a worklet is run, it generates a log entry. These logs are available in the "Logs" tab at the bottom of the page. Each log contains a timestamp, application and run ids, and the worklet run's output, state, and logs. Write to worklet logs from code blocks with the print() function.

Logs are fully searchable by string or regular expression, and can be filtered to any time range. Default ranges from the past five minutes to the past week are built-in, but you can use the calendar to select logs from any date.

Last updated