Skip to content

goodforenergy/gulp-mocha-phantomjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-mocha-phantomjs Build Status

run client-side Mocha tests with PhantomJS

Installation

node

$ npm install gulp-mocha-phantomjs --save-dev

Usage

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mocha Test Runner</title>
    <link rel="stylesheet" href="bower_components/mocha/mocha.css">
  </head>
  <body>
    <div id="mocha"></div>
    <script src="bower_components/mocha/mocha.js"></script>
    <script src="bower_components/should/should.js"></script>
    <script>mocha.setup('bdd')</script>
    <script src="spec/test.js"></script>
    <script>
      if (window.mochaPhantomJS) {
        mochaPhantomJS.run();
      } else {
        mocha.run();
      }
    </script>
  </body>
</html>
var gulp = require('gulp');
var mochaPhantomJS = require('gulp-mocha-phantomjs');

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

The reporter can be chosen by supplying an object with reporter property:

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

You can set the dump option to write the results of mocha tests in a file:

gulp.task('test', function () {
  return gulp
  .src('test/runner.html')
  .pipe(mochaPhantomJS({reporter: 'xunit', dump:'test.xml'}));
});

To test against remote by url:

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

License

MIT

About

run client-side Mocha tests with PhantomJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published