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

muttley

v1.0.13

Published

Monitor Unit Test Tool

Downloads

30

Readme

mutt - Monitor Unit Test Tool

code style: prettier

Intro

mutt is a command line tool for watching unit test dependencies and running tests. By default it uses commonJS module loading for dependencies and mocha for test running. Config settings allow the dependency discovery and test runner to be customised.

To run it just type 'mutt' or 'npm start'.

It then finds all the module dependencies for those files and monitors them, re-running the tests when anything changes.

The UI is inspired by the unix command 'top'. Type 'q' to quit and 'h' to see other commands.

How it works

  • test detection - it scans the folder reading each .js file and regex matches for bdd style tests
  • dependencies - it looks at the imports of each test file (in commonJS require form) and follows these, ignoring node_modules. This can be customised to use a different mechanism by supplying another module for this and specifying it in the config setting dependencyModule. It must have the same exports as src/dependency.ts.
  • watch for changes - it periodicaly (see config setting refreshIntervalMs) checks the mtime on each monitored file and re-runs any tests invalidated.
  • run test - on each file it thinks is a test file it runs mocha --reporter=xunit and parses the output. The test runner can be changed by settings in the config file - testCmd and testArgs.

Usage

From the package folder you can run mutt on itself to see how it works

  • mutt src to monitor mutt's own unit tests
  • mutt demo to see it on the demo folder. The demo folder has some failing tests to illustrate mutt features. Type 'z' to see details of the failures or '1' to see source code.

Docker

There is a Dockerfile which can be used as the basis for your own docker based test watcher. The default file builds mutt, runs it's tests and runs the app on itself.

docker build  -t mutt .
docker run -it mutt

Use docker run with -v and -w to map your code into the docker image.

Know Issues

  • mocha and source-map-support need to be installed globally or the process.exec won't find them
  • It seems there are bugs in the xunit reporter for mocha so there are cases the XML does not contain all the tests. If you think mutt is not showing all your tests, run mocha cli with --reporter=xunit and check the output.
  • Windows support - ymmv - you may be better off using the docker image

npm scripts

  • build - tsc build
  • watch - tsc -w build
  • test - run tests mocha
  • jest - run tests with jest
  • cover - run test with coverage stats in jest
  • lint - run eslint
  • pretty - run prettier
  • pretty-write - run prettier --write
  • start - run mutt

mutt -h

mutt [paths...]
Monitor all Unit Tests in the paths. If no paths supplied use current directory.

Positionals:
  paths  paths to watch                                  [string] [default: "."]

Options:
  --version      Show version number                                   [boolean]
  --verbose, -v  Log to file. Pass info|debug|warn etc                 [string]
  --help, -h     Show help                                             [boolean]