Giter Site home page Giter Site logo

mochify.js's Introduction

Mochify

Build Status SemVer License

TDD with Browserify, Mocha, PhantomJS and WebDriver

  • Fast roundtrip
  • No test HTML page
  • No server
  • Selenium WebDriver & SauceLabs support
  • Code coverage with coverify
  • Short stack traces with relative paths
  • Works with most Mocha reporters

Install

npm install mochify -g
  • Download and install Phantom.JS: http://phantomjs.org/
  • Make sure that the phantomjs executable is in your PATH or use --phantomjs <path>

Usage

From within your project directory:

mochify

Browserifies ./test/*.js, decorated with a Mocha test runner, runs it in PhantomJS with phantomic and pass the output back to your console. Cleans up your stack traces by mapping back to the original sources and throws out all the lines from the test framework.

Run mochify --help to see all available options.

Options:

  • --watch or -w use watchify to watch your files and run the tests on change.
  • --reporter or -R changes the Mocha reporter (see further down).
  • --ui or -U changes the Mocha UI. Defaults to 'bdd'.
  • --timeout or -t changes the Mocha timeout. Defaults to 2000.
  • --debug launches the WebKit debugger.
  • --port uses a specific port for the PhantomJS server.
  • --phantomjs uses a specific PhantomJS executable. If not specified, phantomjs is expected on the $PATH.
  • --cover checks code coverage with coverify.
  • --node runs test cases on node (useful with --cover).
  • --wd use min-webdriver to run the tests in multiple real browsers.
  • --consolify generate a standalone HTML page with consolify.
  • --yields or -y changes the yield interval to allow pending I/O to happen.
  • --version or -v shows the Mochify version number.
  • --help or -h shows usage and all available options.

Example package.json configuration

"devDependencies" : {
  "mocha"         : "*",
  "browserify"    : "*",
  "mochify"       : "*"
},
"scripts"         : {
  "start"         : "mochify --watch"
  "test-phantom"  : "mochify",
  "test-wd"       : "mochify --wd",
  "test"          : "npm run test-phantom && npm run test-wd"
}

Selenium WebDriver setup

mochify

java -jar selenium-server-standalone-2.39.0.jar

Create .min-wd in your project root:

{
  "hostname"  : "localhost",
  "port"      : 4444,
  "browsers"  : [{
    "name"    : "internet explorer",
    "version" : "9"
  }, {
    "name"    : "chrome"
  }, {
    "name"    : "firefox"
  }]
}

That's it! Now mochify --wd will run your Mocha test cases in the configured browsers simultaniously. If you installed mochify without -g, you will have to run node_modules/.bin/mochify --wd.

SauceLabs

Export your SauceLabs credentials:

export SAUCE_USERNAME="your-user-name"
export SAUCE_ACCESS_KEY="your-access-key"

Enable SauceLabs in your .min-wd file:

{
  "sauceLabs": true
}

For more information about Selenium WebDriver and SourceLabs support can be found on the min-webdriver project page.

Reporters

Mocha reporters known to work:

  • min
  • dot (default)
  • list
  • spec
  • tap
  • json
  • doc
  • xunit
  • markdown
  • landing

Note: Consuming the output of a machine readable reporter may not work as expected with --wd.

Compatibility

  • Node 0.10 or later
  • Browserify 5.9 or later (since version 1.0.0)
  • Browserify 4.x (before 1.0.0)

License

MIT

mochify.js's People

Contributors

mantoni avatar andreypopp avatar jprichardson avatar jeromegn avatar

Watchers

James Cloos avatar onceknown avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.