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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jest-config-docusaurus

v0.1.1

Published

Configure Jest to work with Docusaurus

Downloads

311

Readme

jest-config-docusaurus

🃏 A Jest config extension to aid in testing with Docusaurus.

Essentially all it does is tap into your Docusaurus setup and retrieve all the aliases used for Webpack, which it then converts to Jest module mappings so they can be injected into your config. It also ensures transforming can occur with Docusaurus dependencies.

⚠️ This is a work in progress! If you have time and would like to improve this package please go ahead and open a PR.

Usage

Here's how to use this addon:

  • Set up Jest in your project. You'll need a jest.config.js file that exports a config as an async function.
  • Install the dependency with yarn add --dev jest-config-docusaurus or npm i --save-dev jest-config-docusaurus
  • Import the applyConfig helper, call it with your existing config, and return the result as your final config. For example:
import { applyConfig } from "jest-config-docusaurus";

export default async () =>
  await applyConfig({
    // Project-specific config that will be applied as well
    testEnvironment: "jsdom",
    setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
    moduleNameMapper: {
      "^.+\\.(jpg|jpeg|png|svg)$": "<rootDir>/fileMock.js",
      "^.+\\.(css|scss)$": "identity-obj-proxy",
    },
  });

You can also import and call makeConfig directly if you just want to retrieve the config without layering in your own.

Using with TypeScript

If your test setup involves TypeScript you'll probably need to tell TypeScript how to locate the mapped modules as well. This can't be done dynamically, but here's an example tsconfig.json to get you most of the way there:

{
  "extends": "@tsconfig/docusaurus/tsconfig.json",
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      // Import notes about paths for theme-related paths:
      // - @theme paths should point to the topmost component, including swizzled versions
      // - @theme-original paths should point to the topmost component, exluding swizzled versions
      // - @theme-init paths should point to the bottommost component typically the theme or plugin that first provided it
      // This means certain instances of these paths may need to supercede /* wildcards.
      // https://docusaurus.io/docs/next/advanced/client#theme-aliases
      "@theme-original/*": [
        "./node_modules/@docusaurus/theme-classic/lib/theme/*"
      ],
      "@theme-init/*": ["./node_modules/@docusaurus/theme-classic/lib/theme/*"],
      "@theme/*": ["./node_modules/@docusaurus/theme-classic/lib/theme/*"],
      "@docusaurus/*": ["./node_modules/@docusaurus/core/src/client/exports/*"],
      "@site/*": ["./*"],
      "@generated/*": ["./.docusaurus/*"]
    }
  }
}

License

MIT