Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including mocha-setup with all npm packages installed. Try it out:

var mochaSetup = require("mocha-setup")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mocha-setup v0.0.2

🚨 A mocha require file including some basic things I usually use

mocha-setup CircleCI

🚨 A mocha require file including some basic things I usually use

This setup includes the globals:

  • chai functions: assert, expect
  • sinon
  • sinon function: spy, fake, stub
  • abuser

It also extends chai with:

  • chai-as-promised
  • chai-string
  • deep-equal-in-any-order
  • sinon-chai

package.json

  ...
  "test": "mocha '**/spec.js' --require .mocha.js --recursive --exclude 'node_modules'",
  ...

.mocha.js

require('mocha-setup');

// Your other things
process.on('unhandledRejection', error => { throw error; });

.eslintrc.js

const globals = require('mocha-setup/globals');

module.exports = {
    ...
    overrides: [
        {
            files: [ "**/spec.js" ],
            globals
        }
    ]
};

Or add to your own globals

            ...
            globals: Object.assign(globals, {...})
        }

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free