This package has been deprecated

Author message:

Use headless-test instead, as it's more general.

mocha-headless-server

0.1.4 • Public • Published

Use to run Mocha tests via headless browsers (currently just Chrome) via a local HTTP server.

Running a local HTTP server enables resources that require network access (e.g., JS module loading). This will serve files in the current working directory.

Usage

You should have a boilerplate Mocha test file and a suite of tests. You'll need Mocha and Chai added to your project. For a good example of the boilerplate files, check out ok-emoji: harness (HTML), which includes tests (JS)

Binary

From the command-line:

# either of
yarn global add mocha-headless-server
npm install -g mocha-headless-server

# then
mocha-headless-server path/to/test.html

Node

First, add this project as a dev dependency:

# either of
npm install --save-dev mocha-headless-server
yarn add --dev mocha-headless-server

Then you can require() this module and include it in your scripts:

const tester = require('mocha-headless-server');

const options = {
  path: 'path/to/test.html',  // path, required
  log: false,                 // whether to log to console
  headless: true,             // whether to run headless or to show browser
};
const p = tester(options);
p.then((out) => {
  if (out.fail.length) {
    // oh no, a test failed
  }
});

Travis-CI

First, add this project as a dev dependency:

# either of
npm install --save-dev mocha-headless-server
yarn add --dev mocha-headless-server

Then add this script to your package.json:

{
  "scripts": {
    "test": "mocha-headless-server path/to/test.html"
  }
}

Add this .travis.yml file to your project:

language: node_js
dist: trusty
node_js:
  - "node"
addons:
  chrome: stable

And perform the usual steps to set up Travis-CI for your project.

Dependents (0)

Package Sidebar

Install

npm i mocha-headless-server

Weekly Downloads

336

Version

0.1.4

License

Apache-2.0

Unpacked Size

21.5 kB

Total Files

10

Last publish

Collaborators

  • samthor