Skip to content

Test runners

PawelDalek edited this page Dec 5, 2022 · 6 revisions

Test runners

This section is dedicated to test runner-esque scripts that allow to test different ways of exporting (CLI, HTTP and NodeJS module) that concern testing almost every option described in the README. Scripts are located in the /tests folder.

Export methods

There are three basic methods to trigger 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 NodeJS module.

For each of mentioned methods there is a script that triggers export action per 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 then executes the command within that shell. The script accepts JSON objects where the "property": "value" scheme corresponds to the CLI --argument value, described in Command Line Arguments section.

HTTP POSTs

  • 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 to a previously enabled HTTP server. The acceptable options for the payload can be found in the HTTP Server section.

NodeJS module

  • Folder: /tests/node
  • File: node_test_runner.js
  • Command: yarn node-tests | npm run node-tests

This script inits pool of browser instances, 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 that starts the export process when provided with a correct configuration. The Loading JSON Configs describes possible configuration. Although, for the image export purposes, only the export and customCode sections are taken under consideration in this script and all server-related configuration options are omitted.

Other tests

Aside from above scripts there is also the /other folder which contains tests like side_by_side.js comparing old and new servers (both must be run manually before) and stress_tests.js testing multiple requests in a given time.

Clone this wiki locally