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

eslint-plugin-jest-runner-groups-validator

v1.4.0

Published

Validates that Jest runner groups applied to test files are from a known set

Downloads

1,933

Readme

ESLint Jest runner groups validator

Provides an ESLint plugin that validates Jest runner groups applied to tests. These groups are the ones are defined using jest-runner-groups.

This is useful when you would like to restrict groups to a particular subset:

  • in case a group is mis-typed and would not then run in your suite;
  • so that existing groups can be re-used, instead of making new ones accidentally.

Installation

Assuming you have ESLint installed already:

npm install --save-dev eslint-plugin-jest-runner-groups-validator

In your .eslintrc.json (or similar):

{
  "plugins": [
    "jest-runner-groups-validator"
  ],
  "rules": {
    "jest-runner-groups-validator/must-match": "error",
    "jest-runner-groups-validator/top-level": "error"
  }
}

Then in your package.json file, define a property:

{
  squadTags: ["Fast", "Slow", "Smoke"]
  name: ...,
  dependencies: ...
  etc...
}

Configurations

The top-level rule, when enabled, will require that a groups docblock is defined in every file that contains tests, as determined by .test.[ext] files.

The must-match rule will then validate that those groups are restricted to the set of known values in the package.json file, as above. There is a single option in this rule, which allows you to specify the name of the property in the package:

// .eslintrc.json
{
    "jest-runner-groups-validator/must-match": ["error", { "propertyName": "groupings" }]
}

which corresponds with:

// package.json
{
  groupings: ["Fast", "Slow", "Smoke"]
  name: ...,
  dependencies: ...
  etc...
}

The default property is squadTags. You can define this property as either an array:

// package.json
{
  squadTags: ["Fast", "Slow", "Smoke"]
  name: ...,
  dependencies: ...
  etc...
}

// Code allows any of:
/**
 * @group Fast
 * @group Slow
 * @group Smoke
 */

or an object of arrays:

// package.json
{
  squadTags: {
    "sanity": ["Fast", "Smoke", "Sanity"],
    "full": ["Fast", "Slow", "Regression"]
  },
  name: ...,
  dependencies: ...
  etc...
}

// Code allows any of:
/**
 * @group Fast
 * @group Slow
 * @group Smoke
 * @group Sanity
 * @group Regression
 */

Fixes

  • At the top-level, a new comment will be added, with a placeholder group, to the top of the file, if one does not already exist.
    • If one already existed, the plugin will attempt to add placeholder groups to the first block comment in the file.
    • The placeholders will also be reported as errors. Specifically, TODO is not a valid group name and the top text (if it was empty) needs to be replaced.
  • In must-match, there are no fixes. But there are "autocorrect" suggestions for possible group names. e.g.
    /**
     * @group Slo
       ^^^^^^^^^^ Invalid group name 'Slo'. Did you mean 'Slow'?
     */