Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

jest-community/jest-watch-toggle-config

Repository files navigation

Build Statusnpm version

jest-watch-toggle-config

Toggle your Jest boolean config settings at will

Usage

Install

Installjest(it needs Jest 23.4.1+) andjest-watch-toggle-config

yarn add --dev jest jest-watch-toggle-config# or with NPMnpm install --save-dev jest jest-watch-toggle-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, includebail,collectCoverage,noSCM,notify,onlyFailures,passWithNoTests andverbose.
  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 eitheron oroff, 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 yourpackage.json:

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

Or injest.config.js

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

Run Jest in watch mode

yarn jest --watch# or with NPMnpx 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:

OptionKeyPrompt
bailbturn %ONOFF% bailing at first error
collectCoveragee*turn %ONOFF% code coverage collection
notifynturn %ONOFF% desktop notifications
verbosevturn %ONOFF% test verbosity

* Jest already reservesc,o andv

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp