lukechilds / browser-env

Simulates a global browser environment using jsdom
MIT License
174 stars 14 forks source link

TypeError: virtualConsole must be an instance of VirtualConsole #76

Open niftylettuce opened 5 years ago

niftylettuce commented 5 years ago

It seems all options passed to jsdom work except virtualConsole.

const browserEnv = require('browser-env');
const { VirtualConsole, CookieJar } = require('jsdom');

const cookieJar = new CookieJar();
const virtualConsole = new VirtualConsole();

virtualConsole.sendTo(console);

browserEnv({
  url: 'http://localhost:3000/',
  referrer: 'http://localhost:3000/',
  contentType: 'text/html',
  includeNodeLocations: true,
  resources: 'usable',
  runScripts: 'dangerously',
  virtualConsole,
  cookieJar
});
  Uncaught exception in test/browser-env.js

  /Users/user/Projects/parse-request/node_modules/window/node_modules/jsdom/lib/api.js:263

  TypeError: virtualConsole must be an instance of VirtualConsole

  transformOptions (node_modules/window/node_modules/jsdom/lib/api.js:263:11)
  new JSDOM (node_modules/window/node_modules/jsdom/lib/api.js:36:15)
  new Window (node_modules/window/src/index.js:13:11)
  browserEnv (node_modules/browser-env/src/index.js:28:17)
  Object.browserEnv (test/browser-env.js:12:1)

  ✖ test/browser-env.js exited with a non-zero exit code: 1
lukechilds commented 5 years ago

Thanks for taking the time to report this but unfortunately I don't have time to look into this right now due to paid work.

PRs are very welcome.