Giter Site home page Giter Site logo

gulp-jasmine-browser's Introduction

gulp-jasmine-browser

Build Status

Installing

gulp-jasmine-browser is available as an npm package.

Usage

Create a Jasmine server to run specs in a browser

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.

Run jasmine tests headlessly

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.

Run jasmine tests and get xml report (JUNIT)

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).

Usage with Webpack

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());
});

Development

Getting Started

The application requires the following external dependencies:

  • Node
  • Gulp
  • PhantomJS - if you want to run tests with Phantom, see your options under 'Usage.'

The rest of the dependencies are handled through:

npm install

Run tests with:

npm test

(c) Copyright 2015 Pivotal Software, Inc. All Rights Reserved.

gulp-jasmine-browser's People

Contributors

vinsonchuong avatar charleshansen avatar stubbornella avatar rdy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.