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-cli-middleware

v1.1.1

Published

Middleware for jest-cli allowing to adapt default commands from your IDE

Downloads

2

Readme

#Jest CLI Middleware Jest cli middleware is a cli you can use over standard Jest-cli or React-scripts to gain some flexibility, especially with IDE integrations. J.C.M allow you to:

  • JCM can handle testing Environments discriminated by the path of the files and change the cli and it's args according to some rules with the same JEST IDE Config, (example):
    • Run back-end tests (which are in a "server" folder) with jest-cli and --runByPath Transformations.
    • Run front-end tests (which are in the "CRA" folder) with react-scripts
    • JCM takes care of the Working directory automatically for your different Environments
  • JCM handles Transformations to -runByPath argument passed by the IDE CLI call:
    • This allows you to write your tests with typescript, click the IDE button to run a specific test, and have jest called with the JS file.
    • Transformations rules are completely configurable, and they can be different from one to another Environment

#Installation & Configuration

Installation

With yarn

yarn add jest-cli-middleware

With npm

npm install jest-cli-middleware

Configuration

Create the config file

JCM get its configuration from a .jcmrc file with JSON syntax. This config file has to be in the package.json folder.

Configuration file Syntax explained from an example

[
  {
    "jestEvt": "clientApp",
    "pathMatch": "./client",
    "pathTransformers": [],
    "cliScript": "./node_modules/react-scripts/scripts/test.js"
  },
  {
    "jestEvt": "server",
    "pathMatch": "./server",
    "pathTransformers": [{
      "matcher": "server/src",
      "substitute": "server/dist"
    }, {
      "matcher": ".ts",
      "substitute": ".js"
    }, {
      "matcher": ".jsx",
      "substitute": ".jsx"
    }],
    "cliScript": "./node_modules/jest-cli/bin/jest.js"
  }
]
  • The configs object is an array of all the different Environments you want to handle.
  • The config object have the following props:
    • jestEvt: string is just the name of the Environment
    • pathMatch: string is the absolute or relative path of a folder containing all the test you want to run with this config. (ex: path of your CRA)
      • relative path are based from node working directory, which depends on your shell's actual directory at the moment you run JCM; or your IDE configuration if you run JCM from it.
    • pathTransformers?: {matcher: string, substitue: string}[] is an array of transformer objects: this rewrite the --runByPath argument value, each transformer rule catch a matcher string and replace it by the substitute.
    • cliScript: string is the absolute or relative path of the CLI you want to finally run.
      • relative path are based on the path given to pathMatch property.