mocha-testing-skeleton

1.0.1 • Public • Published

Mocha Testing Skeleton

This repo demonstrates how to run mocha + expect.js unit tests in the browser (or headlessly), with tests written in BDD (Behavior Driven Development) style.

Dependencies:

  • mocha - a JavaScript test framework for running tests on Node.js and the browser
  • expect.js - a small BDD-style assertion library
  • mocha-phantomjs - a PhantomJS test runner for running browser tests headlessly

Included files:

  • main.js - the code under test
  • test/index.html - an HTML page that sets up the test infrastructure and enables you to run the tests.
  • test/tests.js - the mocha test suite. The functions "describe()" and "it()" and "afterEach()" are part of mocha; the "expect()" functions are assertion functions that come from expect.js.

Based upon this repo. Altered to meet my needs.

Installing

  1. Install Node.js and npm from NodeJS.org.
  2. Use git to clone this repo on your local machine:
$ git clone https://github.com/mjhea0/mocha-testing-skeleton.git
  1. Enter the repo directory and type make install. This installs the dependencies listed above.

Running the tests manually from a browser

  1. Open the test/index.html file in a browser. This displays a test page that shows two tests passing.
  2. Simply refresh the page to run the test suite again.

Running the tests headlessly using PhantomJS

  1. Run make test and observe the results on the command line.

Readme

Keywords

none

Package Sidebar

Install

npm i mocha-testing-skeleton

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • mjhea0