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-watch-toggle-config-2

v2.1.0

Published

Jest watch plugin for toggling boolean settings (e.g. verbosity, test coverage)

Downloads

482

Readme

jest-watch-toggle-config-2

NPM version NPM downloads

GitHub NodeJS Codecov

Visual Studio Code

This is a fork of jest-watch-toggle-config. It seems like the original plugin is no longer maintained.

Usage

Install

Install jest(it needs Jest 23.4.1+) and jest-watch-toggle-config

yarn add --dev jest jest-watch-toggle-config-2

# or with NPM

npm install --save-dev jest jest-watch-toggle-config-2

This plugin is used in @repobuddy/jest watch config.

Add it to your Jest config

Since Jest 23.3, you can provide per-instance watch plugin configuration. Jest 23.4.1 opens up the list of global configuration settings that can be altered by watch plugins. Together, these evolutions let us use this same plugin in multiple ways, as along as the targeted configuration setting is boolean.

There are three mandatory configuration items you need to provide:

  1. setting is the boolean Jest configuration setting you want to toggle. Boolean settings available for configuration through watch plugins, as of Jest 23.4.1, include bail, collectCoverage, noSCM, notify, onlyFailures, passWithNoTests and verbose.
  2. key is the keyboard key that will be bound to this plugin instance, toggling the setting you’re interested in. We actually provide a default key for each option, trying our best not to step on Jest’s built-in keys, but they might conflict with another plugin's key. So you can tweak it.
  3. prompt is the plugin prompt displayed in the watch menu. In this text, you can use the %ONOFF% placeholder, that will be dynamically replaced by either on or off, depending on the resulting setting value. We also provide good defaults for the options listed above, but feel free to tweak them.

Here’s an example for toggling both test verbosity (details of passed/failed tests) and code coverage collection with this plugin.

In your package.json:

{
  "jest": {
    "watchPlugins": [
      ["jest-watch-toggle-config-2", { "setting": "verbose" }],
      ["jest-watch-toggle-config-2", { "setting": "collectCoverage" }]
    ]
  }
}

Or in jest.config.js

module.exports = {
  // …
  watchPlugins: [
    ['jest-watch-toggle-config-2', { setting: 'verbose' }],
    ['jest-watch-toggle-config-2', { setting: 'collectCoverage' }],
  ],
}

Run Jest in watch mode

yarn jest --watch

# or with NPM

npx jest --watch

List of options that have default keys and prompts

As of Jest 23.4.1, the following boolean options have sane defaults you can leverage to lighten your configuration:

| Option | Key | Prompt | | ------------------------------------------------------------------------------------ | ----- | ------------------------------------- | | bail | b | turn %ONOFF% bailing at first error | | collectCoverage | e* | turn %ONOFF% code coverage collection | | notify | n | turn %ONOFF% desktop notifications | | verbose | v | turn %ONOFF% test verbosity |

* Jest already reserves c, o and v