plotly / plotly/plotly.js

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

Open
#3,239 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by importing Plotly from a component tested with jsdom and Mocha, then inspect node_modules/plotly.js/dist/plotly.js around the first undefined browser function. Trace the additional missing functions and determine the intended test-compatible behavior; done means Plotly imports without the current cascade of browser-function errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization, testing-qa
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.