Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Unit tests: upgrade jsdom to v11 to fix breaking unit tests for Network #3603

Merged
merged 4 commits into from
Oct 28, 2017

Conversation

wimrijnders
Copy link
Contributor

The handling of getContext() in jsdom v9 was broken, and caused unit tests for Network to fail.
The issue has been fixed in jsdom v11, so I upgraded it.

This issue also deals with the fallout of this upgrade:

  • Modules dependent on jsdom needed to be upgraded as well, notably jsdom-global.
  • Replaced mocha-jsdom with jsdom-global. The former has not been updated to deal with the latest jsdom versions.
  • DRY'd the before-code to the init method of canvas-mock, it was getting too unwieldly.
  • Added some extra definitions to .gitignore, not necessarily related to current issue

Further:

jsdom v11 issues a 'helpful' message that getContext() is not supported without canvas. But we've got the canvas mock in place now, which replaces that. The jsdom message does not break the unit test but is an eyesore (exception output), so effort has been made to bury it.

@wimrijnders
Copy link
Contributor Author

To be clear about it: this fix is required to make Network unit tests work properly.

* In particular, this takes care of a 'helpful' message about support of `getContext()`, which in
* practice is a complete eyesore. It's not a problem in our case, because right here we're using
* our own canvas mock to deal with it.
* The unit test run fine with or without this message, it just gets in the way.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment could be as short as "Supresses getContext warning, ..."
And in the "..." Post the original message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original message is an exception trace at least 15 lines long, would prefer not to add that in full. The first line of that is in the code.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I still think this comment could be shortened considerably

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK will shorten.

// Only 'error' is overridden which for current purposes is fine. The other calls we'll deal
// with when they crash, in the event that they get used.
let myConsole = {
error: (msg) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Warning something we can also log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure. But it's not used here so YAGNI until you do.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. I misunderstood and thought we were suppressing warnings by not including them. But now I understand that until a warning is invoked by a test, it's pointless to add it to the mock.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mock upon mock upon mock....pretty soon it's going to be mocks all the way down.

Copy link

@mbroad mbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comments could be more concise, but nothing holding back an approval.
Looks good!

@wimrijnders
Copy link
Contributor Author

@mbroad Fixed the comments, have a look again?

Copy link
Contributor

@yotamberk yotamberk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@yotamberk yotamberk merged commit 773d593 into almende:develop Oct 28, 2017
mojoaxel pushed a commit to visjs/vis_original that referenced this pull request Jun 9, 2019
…rk (almende#3603)

* First working version

* Fix completed for jsdom getContext() issue

* Fixed commenting for review
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants