mochii

0.0.32 • Public • Published

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 😃!

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

Readme

Keywords

none

Package Sidebar

Install

npm i mochii

Weekly Downloads

35

Version

0.0.32

License

ISC

Unpacked Size

4.79 MB

Total Files

36

Last publish

Collaborators

  • jasonlaster11