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

mochii

v0.0.32

Published

A Mochitest CLI & Reporter

Downloads

20

Readme

Mochii

An opinionated mochitest wrapper for running mochitests and reporting the results.

Getting Started

npm i -g mochii

Mochii Runner

Mochii tries to be a thin wrapper around mochitest, with some extra configuration.

mochii browser_dbg-expressions.js
mochii -- --jsdebugger browser_dbg-expressions

Mochii supports some options that will hopefully save you some keystrokes:

  • mozilla-central - path to the repo you want to run the tests
  • test-path - path to the tests you want to run

We recommend creating a bash function or an npm script to save the settings:

Bash Function
function mochi() {
  mochii --mc foo --default-test-path yo -- $1 $2 $3 $4
}
NPM scripts
{
  scripts: {
    mochi: "mochii --mc ../mozilla-central --default-test-path debugger/client/debugger/new --",
    mochid: "yarn mochi -- --jsdebugger -- ",
    mochir: "yarn mochi -- --repeat 10 -- ",
    mochih: "yarn mochi -- --set-env=HEADLESS -- "
  }
}

Our new mochi script is now setup to run the mochitests in the ../mozilla-central with the default test path debugger/client/debugger/new. This is ideal for running the debugger mochitests from debugger.html. We can now run some sweet tests:

yarn mochi  # runs all of the debugger tests
yarn mochi expressions # runs browser_dbg-expressions.js
yarn mochir expressions # runs browser_dbg-expressions.js 3 times
yarn mochih expressions # runs browser_dbg-expressions.js headlessly

yarn mochi devtools/client/debugger/new/test/mochitest/browser_dbg-expressions.js # runs browser_dbg-expressions.js
yarn mochi --repeat 3 expressions # runs browser_dbg-expressions.js 3 times

Prettifying a mochitest log

If you would like to just use mochii reporter, you can run your mochitest in advance and pass the output to mochii.

./mach mochitest browser_dbg-expressions > result.log
mochii --read result.log

Prettifying a Try Task

Try runs can be difficult to understand. Try tasks can be especially difficult to follow because the logs have to be verbose to pinpoint when a test failed. Mochii can help format a try task so that you can focus on the failure.

Step 1: Go to the task and copy the task id

Step 2: Go to your project and run mochii --task <task-id>

You'll get the same mochii output you'd get if you ran yarn mochi locally :smiley:!

Contributing to Mochii

There are two ways to contribute to Mochii

Link a local version so that local changes are seen when you run yarn mochi

git clone
cd mochii
yarn
yarn link

cd <debugger.html>
yarn link mochii
yarn mochih <test>

Work on a known mochitest log. This is the easiest way to quickly update the log format.

cd <debugger.html>
yarn mochih <test>
cp firefox/mochi_log.txt ../mochi/tests/fixtures/unformatted_stack.txt
cd <mochii>
add the test test/index.test.js
jest --watch

  fit("multiple-failes", () => {
    const out = simulateMochitest("mutliple_fails.txt");
    console.log(out)
    expect(out).toMatchSnapshot();
  });

Screenshots