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:
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.After configuring the index, run your server.
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."hierarchy"
— Boolean. Indicates whether to run tests for multilevel hierarchies. Set this property to false
if your server does not implement them.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.
Let’s have a look at the files you can find in the tests/test/
folder:
You may be interested in the following articles: