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

@cprussin/jest-config

v1.4.1

Published

A jest config that sets up runners for unit tests, integration tests, eslint, and prettier

Downloads

2,220

Readme

@cprussin/jest-config v1.4.1Docs


@cprussin/jest-config v1.4.1

This package contains a set of jest configs that set up runners for running unit tests, integration tests, eslint, and prettier.

Installing

Use the package manager of your choice to install:

  • npm: npm install --save-dev @cprussin/jest-config
  • pnpm: pnpm add -D @cprussin/jest-config
  • yarn: yarn add -D @cprussin/jest-config

Usage

  1. Set up your jest.config.js, for example:
export { base as default } from "@cprussin/jest-config";
  1. Run jest to run format checks, lint checks, unit tests, and integration tests, or use --selectProjects to run a subset of checks.

  2. Add scripts to your package.json if you'd like. For instance:

{
  "scripts": {
    "test:format": "jest --selectProjects format",
    "test:integration": "jest --selectProjects integration",
    "test:lint": "jest --selectProjects lint",
    "test:unit": "jest --coverage --selectProjects unit"
  }
}

Projects

Configurations exported with this package will set up the following jest projects:

  • format: Check code style with prettier using jest-runner-prettier.
  • integration: Tests that run out of the integration-tests directory. Functionally not much different than unit, but you can have a separate configuration, different pipeline dependencies, etc.
  • lint: Run eslint checks using jest-runner-eslint.
  • unit: Need I say more?

Running jest will run all four projects. You can run a subset of the projects using jest's --selectProjects argument, as usual.

Options

If you need to, you can extend or wrap the configs generated here by calling the config you want and passing an object as an argument that describes your modifications. The object can have any combination of the following keys:

  • format: Specify extensions or wrappers for the format project.
  • global: Specify extensions or wrappers for the top-level jest config.
  • integration: Specify extensions or wrappers for the integration project.
  • lint: Specify extensions or wrappers for the lint project.
  • unit: Specify extensions or wrappers for the unit project.

The value for each of those keys should be an object containing either or both of config, an object whose values will be spread into the relevant project or global config, and wrapper, a function that should take the config and return a promise containing the final config. For example:

import { base } from "@cprussin/jest-config";

export default base({
  global: {
    wrapper: async (oldGlobalConfig) => doSomethingAsyncWith(oldGlobalConfig),
    config: {
      passWithNoTests: true,
    },
  },
  unit: {
    wrapper: async (oldUnitConfig) => doSomethingAsyncWith(oldUnitConfig),
  },
  format: {
    config: {
      testPathIgnorePatterns: ["foo/*"],
    },
  },
});

Note that the extensions will be spread before calling the wrapper (so the values in the config option will be present in the argument to the wrapper).

Type Aliases

Functions