npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mikemadest/jest-environment-linkedom

v0.0.2

Published

Provides a simple basic config file for using linkedom with Jest in a project, instead of jsdom.

Readme

jest-environment-linkedom

Important: this project was made as a learning experience and is not maintained anymore. If you want a simple config file to play with, this may be for you! If you need a functional config and ready to use in your project, I would recommend looking for other jest-environment-linkedom projects that may provide a better experience.

1. What is this

This will help run Jest tests in the linkedom environment, based on https://jestjs.io/docs/next/configuration#testenvironment-string. Example of a working basic project: https://github.com/mikemadest/example-linkedom. This is an experiment to see what I can get working, WIP.

2. Why the hell

After taking an interest in Linkedom (https://github.com/WebReflection/linkedom) I came upon this discussion and used Stephen Harberman code as starting point (this code).

The goal was just to make basic tests pass.

3. I wanna play too

3.1 Add those dependencies to your package.json:

    "linkedom": "^0.11.0",
    "jest-fake-timers": "^1.0.2",
    "jest-mock": "^27.0.6",
    "jest-util": "^27.0.6",

3.2 After copying the files in a linkedom folder, update jest.config.js to whatever your path is to this file:

module.exports = {
  // ... you other configs ...
  testEnvironment: './linkedom/jest-environment-linkedom.js',
};

You can also update your package.json like:

  "scripts": {
    "test": "react-scripts test  --env=./jest-config/jest-environment-linkedom.js --watchAll=false",
  },

4. Basic test example (jest + react testing library):

import React from 'react';
import {cleanup, screen, render, fireEvent} from '@testing-library/react/pure';

describe('Basic test', () => {
  const mockedHandleClick = jest.fn().mockImplementation(() => {
    console.log('test click');
  });

  beforeAll(() => {
    render(
      <div>
        <p>test</p>
        <p className="searchNode">search</p>
        <button type="button" onClick={mockedHandleClick}>
          click me!
        </button>
      </div>
    );
  });

  afterAll(cleanup);

  it('should render and find content', () => {
    expect(screen.getByText(/search/i)).toBeInTheDocument();
    expect(screen.queryByText('blah')).not.toBeInTheDocument();
    expect(screen.getByRole('button', {name: 'click me!'})).toBeInTheDocument();
  });

  it('should click the button', () => {
    fireEvent.click(screen.getByRole('button', {name: 'click me!'}));
    expect(mockedHandleClick).toHaveBeenCalled();
  });
});

5. What was done

  • Added window.location to avoid crash

  • Axe test require NamedNodeMap which was undefined. Very crude "fix" just to avoid the crash (JSDOM as a full implementation but for now I'm skipping that)

  • testing library toBeInTheDocument (and probably other methods) uses getRootNode which was undefined, added a "polyfill"

  • Missing getComputedStyle, reported here too: https://githubmemory.com/repo/WebReflection/linkedom/issues/53 So I added a "polyfill" which mostly avoid errors for now

  • extends jest-env-node to avoid reinventing the wheel and avoid setting global.RegExp as this is breaks instanceof.

More on that last one:

Problem is that Object in VM context are different distinct objects. References for that issue: https://github.com/jsdom/jsdom/compare/7.0.1...7.0.2 where jsdom avoided adding Date and RegExp to "this" for the same reason.

Jest globals differ from Node globals: https://github.com/facebook/jest/issues/2549

vm instanceof operator don't work as expected: https://github.com/nodejs/node-v0.x-archive/issues/1277

6. Status

  • render and content checking pass.
  • RegExp are now working
  • onClick test fail: work in progress for a pull request to implement event bubbling in linkedom