Closed rjwills28 closed 1 year ago
So I'll preface this by saying I know very little about Javascript testing or Jest.
It seems wrong that you have to manually import this into each and every test file that needs it. Especially as it'll be easy to forget to do this in the future - missing it only produces warnings, not errors, which could easily be overlooked when writing new tests.
I had a look through the docs and think a Setup section in package.json
(or a separate Setup File, documented further down that page) may allow you to automatically bring this dependency into all tests without having to modify each one?
I suppose this approach is only valid if importing this module has no side-effects on tests that don't need it.
Thanks for the suggestion! It is indeed possible to require the module for all tests and it has no impact on other tests that don't need it. Much cleaner solution.
A lot of console errors get printed when running the tests. These do not stop the test from failing but are quite annoying. See full details in issue #22.
The fix is to import the "jest-canvas-mock" module in the tests that end up calling the plotly.js module down the line.