Skip to content

Test runners

PawelDalek edited this page Jan 21, 2025 · 5 revisions

Test runners

This section is dedicated to test runner-esque scripts that allow testing various methods of exporting (CLI, HTTP, and Node.js module), covering almost every option described in the README. The scripts are located in the /tests folder.

Export methods

There are three basic methods to trigger the exporting process:

  • Using CLI (e.g. highcharts-export-server --infile chart.json --outfile chart.png).
  • Sending POST requests to a previously enabled server (highcharts-export-server --enableServer 1).
  • Directly calling the singleExport, batchExport, or startExport function in a Node.js module.

For each of the mentioned methods, there is a script that triggers the export action for a set of options from a file. These files are located in the /scenarios folders. Every successful scenario will result in an exported image file of a specified type saved in the corresponding /_results folder. There are two runner scripts: one for executing all scenarios and another for a single run.

CLI

  • Folder: /tests/cli
  • Files: cliTestRunner.js | cliTestRunnerSingle.js
  • Command: node ./tests/cli/cliTestRunner.js | node ./tests/cli/cliTestRunnerSingle.js <scenarioFile.json>

This script simulates CLI export by creating a child process that spawns a shell and then executes the specified command within that shell. The script accepts JSON objects where the "property": "value" scheme corresponds to the CLI --argument value, as described in the Command Line Arguments section.

HTTP POST

  • Folder: /tests/http
  • File: httpTestRunner.js | httpTestRunnerSingle.js
  • Command: node ./tests/http/httpTestRunner.js | node ./tests/http/httpTestRunnerSingle.js <scenarioFile.json>

This script sends POST requests by executing CURL commands (CURL needs to be installed) to a previously enabled HTTP server. The acceptable options for the payload can be found in the HTTP Server section.

Node.js module

  • Folder: /tests/node
  • File: nodeTestRunner.js | nodeTestRunnerSingle.js
  • Command: node ./tests/node/nodeTestRunner.js | node ./tests/node/nodeTestRunnerSingle.js <scenarioFile.json>

This script initializes a pool of pages, loads the default options (from the lib/schemas/config.js file), and merges custom options from each scenario file. Next, it runs the startExport function, which is the main function for the export process when provided with correct configuration.

The Configuration section describes possible configurations. However, for image export purposes, only the export and customCode sections are considered in this script, and all server-related configuration options are omitted.

Other tests

In addition to the aforementioned scripts, there is also a /other folder containing tests such as sideBySide.js, which compares old and new servers (both must be run manually beforehand), and stressTests.js, which tests multiple requests within a given time.

Clone this wiki locally