Sign Up

Testing

In Twidget, you can easily test your endpoints and functions directly within our code builder. This guide will walk you through the steps to efficiently test your functions to ensure they meet your requirements.

-

Running Tests

To start testing, follow these steps:

  1. Open Code Builder:

    • Navigate to the code builder where you have your function or endpoint defined.
  2. Click Run & Test:

    • At the top of the builder, you will see a button labeled Run & Test. Click on this button to open the test sidebar.

Test Sidebar Overview

Once the test sidebar is open, you can proceed with specifying the test inputs and assertions.

Specifying Input Values

In the test sidebar, you have the option to define the input values that your function will be tested with:

  1. Input Fields:

    • Fill in the values that you wish to pass to your function.

Adding Assertions

Assertions are used to validate the results of your function tests. You can add multiple assertions to ensure thorough testing:

  1. Assertions Section:

    • Use this section to add different assertions.
  1. Types of Assertions:

    • Equality: Check if the result equals a specific value.

    • Comparison: Validate if the result is greater than, less than, etc.

    • Multiple Assertions: Add multiple conditions to fully test your function's logic.

Test Success and Failure

  • Test Success: A test will pass only if all the assertions specified are true.

  • Test Failure: If any assertion is false, the test will fail.

Saving and Managing Tests

Twidget allows you to save your tests for future use and manage multiple tests efficiently:

  • Save Tests: After configuring your test inputs and assertions, you can save the test for future runs.

  • Create Multiple Tests: You can create as many tests as needed to cover different scenarios.

  • Run Tests Individually or All at Once:

    • Individual Run: Execute a single test to check specific functionality.

    • Run All: Execute all the tests at once to quickly verify multiple conditions.

By following these guidelines, you can ensure your functions and endpoints perform as expected in various scenarios.

Related Topics

Global Variables

Global variables in Twidget are key-value pairs that can be used anywhere across events, endpoints, and functions. They provide a powerful way to manage and share data throughout your projects. Key Features. - Data Types: Global variables support text, number, boolean, and date data types. - Securit...

Command Output

Some commands in Twidget return outputs, which are essential for dynamic and conditional logic within your workflows. These outputs are displayed next to the command and are prefixed with an "as" to indicate the variable name. Using Output Variables. Once a command returns an output, you can use the...

Data Types

Twidget supports six main data types to facilitate interactions within the platform. These data types are essential for defining inputs, outputs, and table fields, helping users understand the nature of the data being handled. The available data types in Twidget are as follows: Text. - Description: ...

Commands in Twidget

Commands are the building blocks of Twidget's no-code platform. They function like code statements and can perform various operations such as creating and updating variables, loops, conditionals, retrieving and manipulating data in the datastore, and much more. Creating a Command. 1. Navigate to the...

Output

Each function also has an optional output where you can return an output variable. To simplify the use of functions, you can define an output schema. The output schema acts as an internal documentation detailing what the output of the function will look like. This makes it easier to understand and u...