gulp-jasmine-browser
is available as an
npm package.
In gulpfile.js
var gulp = require('gulp');
var jasmineBrowser = require('gulp-jasmine-browser');
gulp.task('jasmine', function() {
return gulp.src(['src/**/*.js', 'spec/**/*_spec.js'])
.pipe(jasmineBrowser.specRunner())
.pipe(jasmineBrowser.server());
});
In gulp.src
include all files you need for testing other than jasmine itself.
This should include your spec files, and may also include your production JavaScript and
CSS files.
In gulpfile.js
var gulp = require('gulp');
var jasmineBrowser = require('gulp-jasmine-browser');
gulp.task('jasmine-phantom', function() {
return gulp.src(['src/**/*.js', 'spec/**/*_spec.js'])
.pipe(jasmineBrowser.specRunner({console: true}))
.pipe(jasmineBrowser.phantomjs());
});
Note the {console: true}
passed into specRunner.
In gulpfile.js
var gulp = require('gulp');
var jasmineBrowser = require('gulp-jasmine-browser');
gulp.task('jasmine-phantom', function() {
return gulp.src(['src/**/*.js', 'spec/**/*_spec.js'])
.pipe(jasmineBrowser.specRunner({xml: true}))
.pipe(jasmineBrowser.phantomjs({xml: true, out: 'path/to/file.xml'}));
});
Note the {xml: true}
passed into specRunner and phantjomjs. With the {out: ''}
property you can decide where the output
shall be placed and how it shall be named (defaults to report.xml).
If you would like to compile your front end assets with Webpack, for example to use commonjs style require statements, you can pipe the compiled assets into GulpJasmineBrowser.
In gulpfile.js
var gulp = require('gulp');
var jasmineBrowser = require('gulp-jasmine-browser');
var webpack = require('gulp-webpack');
gulp.task('jasmine', function() {
return gulp.src('spec/**/*_spec.js'])
.pipe(webpack({watch: true, output: {filename: 'spec.js'}}))
.pipe(jasmineBrowser.specRunner())
.pipe(jasmineBrowser.server());
});
The application requires the following external dependencies:
The rest of the dependencies are handled through:
npm install
Run tests with:
npm test
(c) Copyright 2015 Pivotal Software, Inc. All Rights Reserved.