amcharts3-react icon indicating copy to clipboard operation
amcharts3-react copied to clipboard

Test cases failing: ReferenceError: AmCharts is not defined

Open vikramgupta1988 opened this issue 5 years ago • 1 comments

While running testcases using Jest and Enzyme. I get an error like below.

ReferenceError: AmCharts is not defined at node_modules/@amcharts/amcharts3-react/amcharts3-react.js:253:3 at Object.<anonymous> (node_modules/@amcharts/amcharts3-react/amcharts3-react.js:298:3) at Object.<anonymous> (node_modules/@amcharts/amcharts3-react/index.js:6:3)

The AmCharts are imported in my project like below import AmCharts from '@amcharts/amcharts3-react'

I found a solution that is to be added to amcharts-react plugin at line 252. var AmCharts = AmCharts || {}; This is solving the issue. Can I create a PR for this?

Or alternatively can we ignore the import while running the test case?

vikramgupta1988 avatar Dec 19 '18 06:12 vikramgupta1988

I would recommend the use of setupFiles to inject amCharts files to the environment.

darlesson avatar Dec 19 '18 06:12 darlesson