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.1. To pass our tests, your server should have an appropriately configured test index:
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.
Complete the steps below to download, configure, and run our tests:
Step 2.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.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:
Tests can be adjusted to your custom data source API implementation through the tests/config.json
file. It contains the following configuration properties:
Property/Type | Description |
---|---|
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 |
Indicates whether to run tests for value filters. Set this property to true if you have implemented value filters.Note that these tests will work correctly only if your server:
Default value: false . |
hierarchy Boolean |
Indicates whether to run tests for multilevel hierarchies. Set this property to true if you have implemented advanced hierarchical filters.Note that these tests will work correctly only if your server implements version 2.8.5 of the custom data source API. See how to check your custom data source API version. Default value: false . |
Let's have a look at the files you can find in the tests/test/
folder:
You may be interested in the following articles: