Skip to content
Spencer Childress edited this page Aug 6, 2018 · 10 revisions

Testing

Starting with version 1.8, webcharts includes a series of automated unit tests (saved in the \test folder) implemented with mocha, expect and jsdom. Developers can run the tests via npm test. The tests are also run using TravisCI whenever code is pushed to github.

A subset of the tests are rendered here as visual tests to facilitate user testing. (Inspired by this nice implementation from datahub-ui.)

Instructions on how to add new tests are below.

Creating Tests

All tests are saved in the \test folder. Functional tests use a standard mocha/expect workflow, while visual tests have a custom framework.

Functional Tests

Tests for core webcharts functionality can be added by creating a new javascript file (or updating an existing file) in the subfolder under /test. See the existing examples and/or the mocha, expect and jsdom for more details.

Visual Tests

Our visual test sheet provides an easy way to visually examine a wide range of webcharts charts, and there is a standard set of functional tests run on each example as well! The visual test cases are divided in to test suites (specified here) To add new visual tests, the developer must provide valid data and settings for the charts. This is best accomplished with the following steps:

  1. If it's not there already, save the csv data for the chart under \test\samples\data\, otherwise skip this step.
  2. Save the config objects for the charts in a json array under \test\samples\chart-config\. Each object should be a valid webcharts config object with the following additional fields:
  • label required - Briefly describe the test case (string)
  • filename required - path of the csv (string)
  • notes - More details about the test case (string)
  • tests - Describe the tests that should be performed (array of string)
  1. If you created a new json file for your tests in step 2, add it to \test\samples\chart-config\testSettingsList.json, otherwise skip this step. Make sure to specify a type of "table" or "chart".
  2. Open up the visual test sheet, select the appropriate branch and make sure the chart rendered as expected.
  3. Run npm test to make sure the new config-object passes the standard set of unit tests for chart configuration.

Chart Configuration Tests

The webcharts-tests library contains a chart configuration application that allows the user to compare different versions of Webcharts and how new and updated chart settings affect the chart.

Clone this wiki locally