Chevron DownAPI Reference


This utility generates a series of test cases to be used with testLayer that checks the conformance of a layer class.


Example of layer unit tests using tape. The test utility itself is test framework agnostic.

import test from 'tape-catch';
import {testLayer, generateLayerTests} from '';
import {GeoJsonLayer} from '';

test('GeoJsonLayer#tests', t => {
  const testCases = generateLayerTests({
    Layer: GeoJsonLayer,
    sampleProps: {
      data: SAMPLE_GEOJSON
    assert: ({layer, subLayers}) => {
      t.ok(layer.state.features, 'should update features');, layer.props.stroked ? 2 : 1, 'correct number of sublayers');

  testLayer({Layer: GeoJsonLayer, testCases});



generateLayerTests({Layer, sampleProps, assert, onError});
  • Layer (Object) - the layer component class to test
  • sampleProps (Object, Optional) - a list of props to use as the basis for all generated tests. Can be used to supply a meaningful set of data.
  • assert (Function, optional) - callback when checking a condition. Receives two arguments:
    • condition - a value that is expected to be truthy
    • comment (String) - information about the check
  • onBeforeUpdate - custom callback to be added to each test case.
  • onAfterUpdate - custom callback to be added to each test case.