Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR tests are run in JSDOM env and rely on document #1577

Open
jhsware opened this issue Oct 28, 2021 · 4 comments
Open

SSR tests are run in JSDOM env and rely on document #1577

jhsware opened this issue Oct 28, 2021 · 4 comments

Comments

@jhsware
Copy link
Contributor

jhsware commented Oct 28, 2021

Observed Behaviour

All server rendering tests are run with JSDOM-environment exposing document which isn't available in node during SSR.

Expected Current Behaviour

We should run *.spec.server.jsx with separate config file and testEnvironment: "node"

@iambumblehead
Copy link
Contributor

it would be great if inferno_hydrate could use a configurable dom object, as in

import { hydrate } from 'inferno-hydrate';
import jsdom from 'jsdom'

const dom = new jsdom.JSDOM(
  '<!DOCTYPE html><body><div></div></body>')

hydrate(
  createElement('div', { className: 'test' }, "I'm a child!"),
  dom.window.document.body.firstChild,
  dom // optional, configurable dom definition 
);

This would allow inferno_hydrate to be used in concurrently running unit-tests inside a node runtime and without setting global dom variables. Currently, using inferno_hydrate inside node requires global variables and so concurrent tests cannot be used. eg, currently something like this is needed...

import { hydrate } from 'inferno-hydrate';
import jsdom from 'jsdom'

const dom = new jsdom.JSDOM(
  '<!DOCTYPE html><body><div></div></body>')
global.window = dom.window
global.document = dom.window.document

hydrate(
  createElement('div', { className: 'test' }, "I'm a child!"),
  dom.window.document.body.firstChild);

@Havunen
Copy link
Member

Havunen commented Nov 14, 2023

Good idea. Do you want to submit a PR for it?

@Havunen
Copy link
Member

Havunen commented Nov 14, 2023

This could probably be a inferno-wide option to set the DOM.

@iambumblehead
Copy link
Contributor

thanks for the welcoming reply I will think about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants