Skip to content

Test runners

PawelDalek edited this page Feb 15, 2024 · 4 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 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.

CLI

  • Folder: /tests/cli
  • File: cli_test_runner.js
  • Command: yarn cli-tests | npm run cli-tests

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: http_test_runner.js
  • Command: yarn http-tests | npm run http-tests

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: node_test_runner.js
  • Command: yarn node-tests | npm run node-tests

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 initiating 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 side_by_side.js, which compares old and new servers (both must be run manually beforehand), and stress_tests.js, which tests multiple requests within a given time.

Clone this wiki locally