首页 > 解决方案 > 在 reactjs 中用 amCharts4 开玩笑

问题描述

使用amcharts4. 我试过使用

"jest": {
"transformIgnorePatterns": [
  "[/\\\\]node_modules[/\\\\](?!(@amcharts)\\/).+\\.(js|jsx|ts|tsx)$"
],}

但这并没有解决问题。的文档amCharts提到它可以使用jestwith来解决puppeteer。有人知道这个问题的任何其他解决方法吗?使用jestwithpuppeteer是唯一的解决方案吗?

标签: reactjsjestjsamchartsamcharts4

解决方案


我们需要在jest配置中添加以下代码,如果您mount/shallow用于测试,请移至ReactDOM.render()asjest不支持测试SVG和内部amCharts使用SVG

"jest": {
 "transformIgnorePatterns": [
    "node_modules[/\\\\](?!@amcharts[/\\\\]amcharts4)"
 ]
}

推荐阅读