WebReflection / WebReflection/linkedom

Question: Any projects based on this that ARE trying to be complete like JSDOM?

Open
#198 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
2.1k
Forks
104
PR merge metrics
No merged PRs in 30d

Description

This is a cool project! Context: I'm dealing right now with trying to figure out how to have tests for React components that don't take forever to run, can live in a clean plain old node environment instead of Jest's parallel universe, use tap's API instead of the code poetry like expect(thing).toHave.something('i can never remember this junk').that.isnt.Null(), etc.

I have it working now, but the big bottleneck is jsdom. Every component test takes like 5-10 seconds to spin up, at minimum, for a test that runs in 50ms or less. If they do anything interesting with the dom (which a lot of them do), it gets much worse. I'm starting to see why jest runs tests in the parallel universe that it does.

It seems like @testing-library/react and @testing-library/userevents can almost work, but there are some missing pieces (by design, I realize). I totally understand not wanting to add those pieces to linkedom, and agree with that principle entirely.

So the question is, is there a project you're aware of that uses linkedom under the hood, but then does add that extra stuff? Some of what seem to be missing that I've run into:

  • Location isn't set. (Can kinda hack around it by setting window.location to a URL object, which is close enough, but a proper Location polyfill would obviously be needed for anything doing actual navigation.)
  • Navigator has userAgent, but navigator.clipboard is missing.
  • Document.createRange() returns an object that doen'st have setStart and setEnd methods.

I'm thinking it'd be possible to create a set of polyfills for all these things, and probably end up with something that would really only lack some of the finer points of JSDOM's tree structure, but still be close enough to simulate a browser for react testing.

Is someone doing this already? Or, if not, is there some reason you know of why linkedom isn't a suitable base for something like this?

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

This is an exploratory question rather than a scoped change, and it names no repository files or tests. Start by reviewing LinkeDOM's handling of Location, navigator.clipboard, and Document.createRange(), then determine whether an existing project or a new polyfill layer should provide the missing browser behavior. Done would require an agreed scope and implementation plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
testing, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.