Get Free Trial
  1. API reference
Connecting to Data Source
  1. Supported data sources
  2. Connecting to other data sources
Configuring the component
  • Documentation for older versions
  • Table of contents

    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.

    Our testing program works for any server implementing the custom data source API. It sends requests to your back end and expects a specific response in return.

    Testing your server requires two stages:

    1. Prepare your server
    2. Run the tests

    Prepare your server

    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.

    After configuring the index, run your server.

    Run the tests

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

    Step 1. You can find the test suite on our GitHub. Download the repository as a .zip archive or clone it with the following command:

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

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

    npm install

    Step 3. The next step is to adjust the tests to your server. Open the tests/config.json file and specify the following properties:

    • "url" — String. The path to your API endpoints (e.g., http://localhost:3400/api/cube).
    • "emptyValue" — Any value. Defines how your server should treat null or undefined values (e.g., as empty strings).
    • "valueFilters" — Boolean. Indicates whether to run tests for value filters. Set this property to false if your server does not implement them.
      Note that these tests will work if your server:
    • "hierarchy" — Boolean. Indicates whether to run tests for multilevel hierarchies. Set this property to false if your server does not implement them.
      Note that these tests will work if your server implements version 2.8.5 of the custom data source API. See how to check your version.

    Step 4. Start your custom data source API server if it’s not running yet.

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

    npm test

    You will see test results in the console.

    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: