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

@monosmith/jest-preset

v0.2.1

Published

The Jest preset every MonoSmith monorepo uses: the values @nx/jest/preset provided, a TypeScript-aware resolver (tsconfig paths, types-only modules) wired in, and an asset transform for React projects.

Readme

@monosmith/jest-preset

The Jest preset every MonoSmith (smith) monorepo uses. One line in a project's Jest config, and no helper files at the workspace root.

// jest.config.js (or .ts, .cjs)
module.exports = {
  preset: '@monosmith/jest-preset',
}

Why this exists

smith convert takes Nx out of a workspace, and Nx provided three things Jest needs: the preset values (@nx/jest/preset), a resolver that falls back to TypeScript (@nx/jest/plugins/resolver) and, for React projects, a transformer for the files a bundler would load as assets (@nx/react/plugins/jest). Convert used to write those out as files at the workspace root (jest.resolver.cjs, jest.asset-transform.cjs, a rewritten jest.preset.js). They looked like clutter, so a tidy user deleted them and every package's tests broke (issue #447). They are this package now: one devDependency, upgraded with npm update, tested here.

What the preset sets

| Key | Value | |---|---| | testMatch | **/?(*.)+(spec\|test).?([mc])[jt]s?(x) | | moduleFileExtensions | ts, js, mts, mjs, cts, cjs, html | | moduleNameMapper | ./x.js resolves to ./x (an ESM-style import of a TypeScript file) | | transform | ts-jest over TypeScript, JavaScript and HTML, reading <rootDir>/tsconfig.spec.json | | resolver | the TypeScript-aware resolver below, wired in by the preset | | testEnvironment | jsdom (set testEnvironment: 'node' in a Node project) | | testEnvironmentOptions | customExportConditions: ['node', 'require', 'default'] | | modulePathIgnorePatterns | <rootDir>/dist/, <rootDir>/out-tsc/ | | coverageReporters | html |

These are the values @nx/jest/preset provided, so a converted workspace keeps testing the way it did. Whatever a project writes beside preset wins, and Jest merges moduleNameMapper and transform instead of replacing them.

The resolver

Jest's own resolution runs first. When it cannot find a module, TypeScript is asked, reading the first of tsconfig.spec.json, tsconfig.test.json, tsconfig.jest.json and tsconfig.json above the project's root. That finds:

  • what a tsconfig paths entry names (@lib/greet), and
  • a module that only has types: jest.mock('vscode') with just @types/vscode installed, which the mock replaces anyway.

When neither finds it, you get Jest's own Cannot find module error. TypeScript is optional: without it the resolver is Jest's.

To use the resolver without the preset: resolver: require.resolve('@monosmith/jest-preset/resolver').

React projects

module.exports = {
  preset: '@monosmith/jest-preset/react',
}

The base preset plus what @nx/react added to a project's Jest config:

  • tsx and jsx join the module file extensions;
  • scripts go through babel-jest with @babel/preset-env, @babel/preset-typescript and @babel/preset-react (automatic runtime);
  • every other file that is not JavaScript, TypeScript, CSS or JSON goes through the asset transform: an imported SVG is a module whose default export is its file name and whose ReactComponent is a component named as SVGR names it (my-logo.svg is SvgMyLogo); any other file is its file name.

The asset transform alone, for a config with its own transform table, is '@monosmith/jest-preset/asset-transform':

transform: {
  '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@monosmith/jest-preset/asset-transform',
}

Peer dependencies

Nothing is installed for you beyond Jest itself. Add what your project uses:

| Package | When | |---|---| | jest | always | | ts-jest, typescript | the base preset (its transform and the resolver's fallback) | | jest-environment-jsdom | the default testEnvironment (jsdom) | | babel-jest, @babel/preset-env, @babel/preset-typescript, @babel/preset-react | the /react preset (use Babel 7 presets with babel-jest 30) | | @swc/jest | optional: when your transform table uses it, the asset transform hands scripts to it instead of babel-jest |

Layout

The package is plain CommonJS that Jest loads directly: nothing is compiled. The files at the package root are the doors Jest and consumers use (jest-preset.cjs is the name Jest looks for, react/jest-preset.cjs for the sub-preset); the code is three small slices under src/: preset (the values), resolver and asset-transform. The specs sit beside the code and the integration spec runs the real Jest binary over throwaway projects that use the preset.

License

MIT