plotly / plotly/plotly.js

Cannot run jsdom unit tests for files that import Plotly due to missing browser functions

未关闭
#3,239 11 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P2
主要语言
JavaScript
星标
18.3k
派生
2k
平均合并
2 天 12 小时
30 天内合并 PR
28

描述

We are using Plotly in our react application and are currently experiencing issues while unit testing components that import the Plotly library either directly, or further down the component tree.

Currently we are using the latest versions of jsdom and mocha to run our unit tests.

It appears the issue is in the Plotly node module, because our unit test suite breaks due to undefined functions in node_modules/plotly.js/dist/plotly.js

For example we get:

ReferenceError: getComputedStyle is not defined

We have attempted to stub that function (as mentioned in the closed issue #1675), but more undefined functions arise and it becomes a bit of a rabbit hole trying to stub all of the missing functions.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

通过从使用 jsdom 和 Mocha 测试的组件中导入 Plotly 来复现该失败,然后检查 node_modules/plotly.js/dist/plotly.js 中第一个未定义浏览器函数附近的代码。跟踪其他缺失的函数,并确定预期的、与测试兼容的行为;当 Plotly 导入时不再出现当前这一连串的浏览器函数错误,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
data-visualization, testing-qa
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。