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

mocha-decaf

v1.1.1

Published

Run Mocha tests in dry run mode

Downloads

725

Readme

mocha-decaf

Run mocha tests in dry-run mode, it's like mocha but without caffeine

Build Status js-standard-style

Install

Using npm

$ npm i mocha-decaf

Alternatively using yarn

$ yarn add mocha-decaf

Usage

  • You can use mocha-decaf to run your tests the same way you use mocha
$ mocha-decaf --recursive

For a complete list of command line arguments and options check Mocha's Documentation

  • You can also run and list the tests programmatically
const { isJSFile, listFiles, listExecutedTests, runMocha } = require('mocha-decaf')
// list the js files under the test directory
const testFiles = listFiles('./test').filter(isJSFile)
// run the tests with the base mocha reporter
const runner = runMocha(testFiles, { reporter: 'base' })
// list the tests executed
const tests = listExecutedTests(runner)
console.log(tests.join('\n'))

For a complete list of the available functions check the API documentation

  • The above code is exported with the following command
$ mocha-list ./test

How is this package useful ?

  • You can use this package to list all the tests that should be run without actually running them to show what your tests are covering to stakeholders

  • You can also do all sorts of stuff before you actually run your tests using mocha like partitioning the tests to run them in batches on different machines in parallel, checkout Mocha's test filters

Notes

  • This package is only useful till mocha implements this functionality, however it doesn't seem this is going to happen in the near future since a PR was submitted 6 years ago and rejected.

How it works

The command simply patches Mocha's test runner to pass any test then calls mocha to run all tests.

Starting from v0.2.0 it also patches before, beforeEach, after and afterEach

Caveats

  • Some mocha arguments won't behave identically when used with mocha-decaf most notably --forbid-only because it should make the tests marked as .only fail however all tests will pass.

License

MIT