All documentation
  • Introduction
  • Connecting to data source
    1. Supported data sources
    2. Connecting to other data sources
  • Browser compatibility
  • Documentation for older versions
  • Testing your custom data source API server

    To check whether your server handles the custom data source API requests as expected, you can use our test suite that covers basic use cases. It sends requests to your back end and expects a specific response in return.

    Our testing program works for any server implementing the custom data source API, no matter the server-side technology used.

    Step 1. Prepare your server

    Step 1.1. To pass our tests, your server should have an appropriately configured test index:

    • As a test dataset, use either data.json or data.csv files.
    • Our tests use the data index in requests to the server. Therefore, create an index with this name for the test data.

    Step 1.2. After configuring the index, run your server.

    Step 2. Run the tests

    Complete the steps below to download, configure, and run our tests:

    Step 2.1. To get our test suite, download it as ZIP or clone it with the following commands:

    git clone https://github.com/flexmonster/api-data-source
    cd api-data-source/tests

    Step 2.2. Install npm dependencies described in package.json:

    npm install

    Step 2.3. Open the tests/config.json file and specify the path to your API endpoints in the url property:

    {
      "url": "path_to_your_server",
      // Other configs
    }

    Step 2.4. The tests/config.json file contains other configurations for the tests. Check them out and adjust if the default values do not work for your server.

    Step 2.5. Run the test suite with the following command:

    npm test

    You will see test results in the console. For example:

    Example of the test results

    Configurations for the tests

    Tests can be adjusted to your custom data source API implementation through the tests/config.json file. It contains the following configuration properties:

    Property/TypeDescription
    url
    String
    The path to your API endpoints.
    Default value: "http://localhost:3400/api/cube".
    emptyValue
    Any value
    Defines how your server should treat null or undefined values from the dataset.
    For example, our sample Node.js server replaces null and undefined values with an empty string (""). In this case, the emptyValue should be "" — then the test suite will expect "" instead of null and undefined in the server’s response.
    Default value: "".
    valueFilters
    Boolean
    Specifies whether to run tests for value filters (true) or not (false).
    Use these tests if you have implemented the custom data source API without multilevel hierarchy support (the advanced property is set to false in the response to the /fields request).
    Default value: false.

    Test overview

    Let's have a look at the files you can find in the tests/test/ folder:

    What's next?

    You may be interested in the following articles: