ultraq / thymeleafjs

A basic implementation of the Thymeleaf templating engine in JavaScript
Apache License 2.0
52 stars 8 forks source link

JSDOM 10, and dropping jsdom-global #4

Closed ultraq closed 6 years ago

ultraq commented 7 years ago

From JSDOM's own wiki and some reading of past issues, the way I'm testing things via jsdom-global is a rather unsupported hack 😛 See: https://github.com/tmpvar/jsdom/wiki/Don't-stuff-jsdom-globals-onto-the-Node-global

In the process of upgrading this dependency, I should also find a way to not have to rely on jsdom-global. I think what I'll need to do is outlined in that wiki article, which is to use the "window" object returned by a new JSDOM instance within the scope of the test, rather than assuming it exists there all the time.

ultraq commented 7 years ago

Hmm, annoyingly, the library I used to shortcut creation of DOM elements, hyperscript, doesn't allow configuration of what "document" means to it, meaning I always get the html-element shim package instead of a JSDOM one 😕 I may have to write my own hyperscript wrapper...

ultraq commented 6 years ago

Oh screw it, even Enzyme recommends copying those globals over into the Node global when doing testing that needs the DOM (see: https://github.com/airbnb/enzyme/blob/master/docs/guides/jsdom.md), so I don't feel so bad doing the same.