AnyChart / AnyChart-React

Intuitive and easy to use React plugin that allows you to create and work with AnyChart JavaScript Charts
https://www.anychart.com
Apache License 2.0
39 stars 30 forks source link

ReferenceError: anychart is not defined #4

Closed brianyang closed 6 years ago

brianyang commented 7 years ago

in this file you have code like this:

https://github.com/AnyChart/AnyChart-React/blob/master/examples/src/simple_dashboard.js#L5

import React from 'react'
import ReactDOM from 'react-dom'
import AnyChart from '../../dist/anychart-react.min.js'

let stage = anychart.graphics.create();
let chart1 = anychart.line([1, 2, 3]);
chart1.bounds(0, 0, '100%', '50%');
let chart2 = anychart.column();
chart2.column([3, 2, 1]);
chart2.line([3, 5, 6]);
chart2.bounds(0, '50%', '100%', '50%');

ReactDOM.render(
  <AnyChart
    instance={stage}
    width={800}
    height={600}
    charts={[chart1, chart2]}
  />, document.getElementById('root'));

but anychart is not defined. when testing this with Jest, the runner will throw an error: ReferenceError: anychart is not defined

how are you supposed to write tests for this?