If we took document as a param (rather than relying on the global) we could use this from node with jsdom