# gulp-mocha-phantomjs

> run client-side Mocha tests with PhantomJS

Latest version **0.12.2** (published 2017-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-mocha-phantomjs
pnpm add gulp-mocha-phantomjs
yarn add gulp-mocha-phantomjs
bun add gulp-mocha-phantomjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.12.2 |
| Published | 2017-11-20 |
| First published | 2014-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 64 |
| Author | Rui Hu |
| Maintainers | mrhooray |
| Keywords | gulpplugin, mocha, phantomjs, test, testing, framework, runner, unit, spec, tdd, bdd |

## Links

- npm: https://www.npmjs.com/package/gulp-mocha-phantomjs
- Repository: https://github.com/mrhooray/gulp-mocha-phantomjs
- Issues: https://github.com/mrhooray/gulp-mocha-phantomjs/issues
- npm.io page: https://npm.io/package/gulp-mocha-phantomjs

## Dependencies (4)

- [through2](https://npm.io/package/through2.md) ^2.0.1
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.7
- [phantomjs-prebuilt](https://npm.io/package/phantomjs-prebuilt.md) ^2.1.4
- [mocha-phantomjs-core](https://npm.io/package/mocha-phantomjs-core.md) ^2.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.12.2 (latest) — 2017-11-20
- 0.12.1 — 2017-02-17
- 0.12.0 — 2016-09-24
- 0.11.0 — 2016-02-01
- 0.10.1 — 2015-09-02
- 0.9.0 — 2015-08-21
- 0.8.1 — 2015-07-24
- 0.8.0 — 2015-07-17
- 0.7.0 — 2015-07-17
- 0.6.1 — 2015-04-06
- 0.6.0 — 2015-04-05
- 0.5.3 — 2014-12-23
- 0.5.2 — 2014-12-23
- 0.5.1 — 2014-10-07
- 0.5.0 — 2014-08-16
- … 17 more at https://npm.io/package/gulp-mocha-phantomjs/versions

## README

# [gulp](https://github.com/wearefractal/gulp)-mocha-phantomjs [![Build Status](https://travis-ci.org/mrhooray/gulp-mocha-phantomjs.svg?branch=master)](https://travis-ci.org/mrhooray/gulp-mocha-phantomjs) [![Build status](https://ci.appveyor.com/api/projects/status/4ngkp3ijx27alr5u?svg=true)](https://ci.appveyor.com/project/mrhooray/gulp-mocha-phantomjs)
> run client-side [Mocha](https://github.com/visionmedia/mocha) tests with [PhantomJS](https://github.com/ariya/phantomjs)

> a simple wrapper for [mocha-phantomjs-core](https://github.com/nathanboktae/mocha-phantomjs-core) library

## Installation
### node
```shell
$ npm install gulp-mocha-phantomjs --save-dev
```

## Usage
```html
<!DOCTYPE html>
<html>
    <head>
        <title>Mocha</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
    </head>
    <body>
        <script src="../node_modules/should/should.js"></script>
        <script src="../node_modules/mocha/mocha.js"></script>
        <script>mocha.setup('bdd')</script>
        <script>
            describe('true', function () {
                it('should be true', function () {
                    true.should.equal(true);
                });
            });
        </script>
        <script>
            mocha.run();
        </script>
    </body>
</html>
```

```javascript
var gulp = require('gulp');
var mochaPhantomJS = require('gulp-mocha-phantomjs');

gulp.task('test', function () {
    return gulp
    .src('test/runner.html')
    .pipe(mochaPhantomJS());
});
```

Reporter can be chosen via `reporter` option:

```javascript
gulp.task('test', function () {
    return gulp
    .src('test/runner.html')
    .pipe(mochaPhantomJS({reporter: 'spec'}));
});
```

Output of mocha tests can be piped into a file via `dump` option:

```javascript
gulp.task('test', function () {
    return gulp
    .src('test/runner.html')
    .pipe(mochaPhantomJS({reporter: 'spec', dump:'test.log'}));
});
```

Test against remote by url:

```javascript
gulp.task('test', function () {
    var stream = mochaPhantomJS();
    stream.write({path: 'http://localhost:8000/index.html'});
    stream.end();
    return stream;
});
```

Suppress PhantomJS’s console output:

```javascript
gulp.task('test', function() {
    return gulp
    .src('test/runner.html')
    .pipe(mochaPhantomJS({
        suppressStdout: true,
        suppressStderr: true
    }));
});
```

Pass options to mocha and/or PhantomJS:

```javascript
gulp.task('test', function () {
    return gulp
    .src('test/runner.html')
    .pipe(mochaPhantomJS({
        reporter: 'tap',
        mocha: {
            grep: 'pattern'
        },
        phantomjs: {
            viewportSize: {
                width: 1024,
                height: 768
            },
            useColors:true
        }
    }));
});
```

## License
MIT

---
_Source: https://npm.io/package/gulp-mocha-phantomjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
