node.js - NodeJS Global, JSdom, Unit test -
this simple question:
when use create dom jsdom:
const dom = (html = '<!doctype html><body></body></html>') => { const domobject = new jsdom(html); const { window } = domobject; const { document } = (domobject).window; global.window = window; global.document = document; global.navigator = { useragent: 'jsdom', language: 'en' }; } module.exports = dom;
and use on test such:
import test 'tape'; import dom 'dom'; // create global dom dom();
and yet when test have document, window , navigator undefined in tests. it's strange, missing something? or making assumption on it's behavior. should approach differently? if how?
thanks!
Comments
Post a Comment