Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added JUnit xml output (via Kelvin Luck @vitch)
Passing console.log from browser to verbose grunt logging
Support for templates as separate node modules
Removed internal requirejs template (see grunt-template-jasmine-requirejs)
General refactor
  • Loading branch information
Jarrod Overson committed Jan 8, 2013
1 parent 81d4568 commit 7fd976a
Show file tree
Hide file tree
Showing 20 changed files with 229 additions and 845 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
@@ -1,5 +1,5 @@
{
"curly": true,
"curly": false,
"eqeqeq": true,
"immed": true,
"latedef": true,
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG
@@ -1,4 +1,11 @@
v0.2.0:
v0.3.0:
date: 2013-01-08
changes:
- Added JUnit xml output (via Kelvin Luck @vitch)
- Passing console.log from browser to verbose grunt logging
- Support for templates as separate node modules
- Removed internal requirejs template (see grunt-template-jasmine-requirejs)
v0.2.0:
date: 2012-12-03
changes:
- Generalized requirejs template config
Expand Down
27 changes: 10 additions & 17 deletions Gruntfile.js
Expand Up @@ -32,28 +32,21 @@ module.exports = function(grunt) {
jasmine: {
options: {
specs: 'test/fixtures/pivotal/spec/*Spec.js',
helpers: 'test/fixtures/pivotal/spec/*Helper.js'
helpers: 'test/fixtures/pivotal/spec/*Helper.js',
junit: {
path: 'junit'
}
},
pivotal: {
src: 'test/fixtures/pivotal/src/**/*.js'
},
customTemplate: {
src: 'test/fixtures/pivotal/src/**/*.js',
options: {
template: 'test/fixtures/customTemplate/custom.tmpl'
}
},
requirejs: {
src: 'test/fixtures/requirejs/src/**/*.js',
options: {
specs: 'test/fixtures/requirejs/spec/*Spec.js',
helpers: 'test/fixtures/requirejs/spec/*Helper.js',
host: 'http://127.0.0.1:<%= connect.test.port %>/',
template: 'requirejs',
templateOptions: {
requireConfig : {
baseUrl: './test/fixtures/requirejs/src/'
}
template: 'test/fixtures/customTemplate/custom.tmpl',
junit: {
path: 'junit/customTemplate',
consolidate: true
}
}
}
Expand All @@ -73,6 +66,6 @@ module.exports = function(grunt) {

grunt.registerTask('watch-test', ['connect', 'watch']);

grunt.registerTask('test', ['jasmine:pivotal', 'jasmine:customTemplate', 'connect', 'jasmine:requirejs', 'nodeunit']);
grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
grunt.registerTask('test', ['jshint', 'jasmine:pivotal', 'jasmine:customTemplate', 'nodeunit']);
grunt.registerTask('default', ['test', 'build-contrib']);
};
107 changes: 25 additions & 82 deletions README.md
Expand Up @@ -31,11 +31,11 @@ Run your tests on your local filesystem or via a server task like [grunt-contrib

#### AMD Support

Includes a SpecRunner template customized for use with AMD modules and requirejs.
Supports AMD tests via the [grunt-template-jasmine-requirejs](https://github.com/jsoverson/grunt-template-jasmine-requirejs) module

#### Customize your SpecRunner with your own template

Supply your own underscore template to automatically build your SpecRunner custom to your use.
Supply your templates that will be used to automatically build the SpecRunner.

#### Example application usage

Expand Down Expand Up @@ -71,8 +71,20 @@ Type: `String|Array`
Type: `String`
Default: `_SpecRunner.html`

This is the auto-generated specfile that phantomjs will use to run your tests. This is automatically deleted upon normal
runs
This is the auto-generated specfile that phantomjs will use to run your tests.
This is automatically deleted upon normal runs

#### options.junit.path
Type: `String`
Default: undefined

Path to output JUnit xml

#### options.junit.consolidate
Type: `Boolean`
Default: `false`

Consolidate the JUnit XML so that there is one file per top level suite.

#### options.host
Type: `String`
Expand All @@ -95,13 +107,15 @@ host : 'http://127.0.0.1:<%= connect.port %>/'
Not defining a host will mean your specs will be run from the local filesystem.

#### options.template
Type: `String`
Default: `default`
Options: `default`, `requirejs`, `yourcustomtemplate.tmpl`
Type: `String` `Object`
Default: undefined

Specify a custom template to use when generating your Spec Runner. Templates are parsed as underscore templates and provided
Specify a custom template used to generate your Spec Runner. Templates are parsed as underscore templates and provided
the expanded list of files needed to build a specrunner.

You can specify an object with a `process` method that will be called as a template function.
See the [Template API Documentation](needs-wiki-link) for more details.

#### options.templateOptions
Type: `Object`
Default: `{}`
Expand All @@ -124,32 +138,6 @@ watch: {
}
```

### Template Options

#### Default template

No specific options are expected or used.

#### RequireJS template

##### templateOptions.requirejs
Type: `String`

The path to requirejs if you need to specify an alternate version.

##### templateOptions.loaderPlugin
Type: `String`

The loader plugin to prefix all loaded `src` files. This is useful for processing
your specs through the likes of CoffeeScript or TypeScript plugins. Keep in mind
you will need to specify the path to the plugin in the require config.

##### templateOptions.requireConfig
Type: `Object`

This object is `JSON.stringify()`-ed into the template and passed into `require.config()`




#### Basic Use
Expand Down Expand Up @@ -193,57 +181,12 @@ grunt.initConfig({
#### Sample RequireJS usage
```js
// Example configuration
grunt.initConfig({
connect: {
test : {
port : 8000
}
}
jasmine: {
requirejs: {
src: 'src/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js',
host: 'http://127.0.0.1:8000/',
template: 'requirejs',
templateOptions: {
requireConfig: {
baseUrl: 'src/'
}
}
}
}
}
}
```
*Note* the usage of the 'connect' task configuration. You will need to use a task like
[grunt-contrib-connect][] if you need to test your tasks on a running server.
[grunt-contrib-connect]: https://github.com/gruntjs/grunt-contrib-connect
#### RequireJS notes
If you end up using the requirejs template, it's worth looking at the
[RequireJS template source](https://github.com/gruntjs/grunt-contrib-jasmine/blob/master/tasks/jasmine/templates/RequireJSRunner.tmpl)
in order to familiarize yourself with how it loads your files. The load process essentially
consists of a series of nested `require` blocks, incrementally loading your source and specs:
```js
require([*YOUR SOURCE*], function() {
require([*YOUR SPECS*], function() {
require([*GRUNT-CONTRIB-JASMINE FILES*], function() {
// at this point your tests are already running.
}
}
}
```
Please see the [grunt-template-jasmine-requirejs](https://github.com/jsoverson/grunt-template-jasmine-requirejs)
## Release History
* 2013-01-07   v0.3.0   Added JUnit xml output (via Kelvin Luck @vitch) Passing console.log from browser to verbose grunt logging Support for templates as separate node modules Removed internal requirejs template (see grunt-template-jasmine-requirejs)
* 2012-12-02   v0.2.0   Generalized requirejs template config Added loader plugin Tests for templates Updated jasmine to 1.3.0
* 2012-11-23   v0.1.2   Updated for new grunt/grunt-contrib apis
* 2012-11-06   v0.1.1   Fixed race condition in requirejs template
Expand All @@ -253,4 +196,4 @@ require([*YOUR SOURCE*], function() {
Task submitted by [Jarrod Overson](http://jarrodoverson.com)
*This file was generated on Thu Dec 13 2012 09:07:25.*
*This file was generated on Tue Jan 08 2013 11:28:08.*
48 changes: 1 addition & 47 deletions docs/jasmine-examples.md
Expand Up @@ -41,50 +41,4 @@ grunt.initConfig({
## Sample RequireJS usage
```js
// Example configuration
grunt.initConfig({
connect: {
test : {
port : 8000
}
}
jasmine: {
requirejs: {
src: 'src/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js',
host: 'http://127.0.0.1:8000/',
template: 'requirejs',
templateOptions: {
requireConfig: {
baseUrl: 'src/'
}
}
}
}
}
}
```
*Note* the usage of the 'connect' task configuration. You will need to use a task like
[grunt-contrib-connect][] if you need to test your tasks on a running server.
[grunt-contrib-connect]: https://github.com/gruntjs/grunt-contrib-connect
## RequireJS notes
If you end up using the requirejs template, it's worth looking at the
[RequireJS template source](https://github.com/gruntjs/grunt-contrib-jasmine/blob/master/tasks/jasmine/templates/RequireJSRunner.tmpl)
in order to familiarize yourself with how it loads your files. The load process essentially
consists of a series of nested `require` blocks, incrementally loading your source and specs:
```js
require([*YOUR SOURCE*], function() {
require([*YOUR SPECS*], function() {
require([*GRUNT-CONTRIB-JASMINE FILES*], function() {
// at this point your tests are already running.
}
}
}
```
Please see the [grunt-template-jasmine-requirejs](https://github.com/jsoverson/grunt-template-jasmine-requirejs)
60 changes: 20 additions & 40 deletions docs/jasmine-options.md
Expand Up @@ -25,8 +25,20 @@ Type: `String|Array`
Type: `String`
Default: `_SpecRunner.html`

This is the auto-generated specfile that phantomjs will use to run your tests. This is automatically deleted upon normal
runs
This is the auto-generated specfile that phantomjs will use to run your tests.
This is automatically deleted upon normal runs

## options.junit.path
Type: `String`
Default: undefined

Path to output JUnit xml

## options.junit.consolidate
Type: `Boolean`
Default: `false`

Consolidate the JUnit XML so that there is one file per top level suite.

## options.host
Type: `String`
Expand All @@ -49,27 +61,21 @@ host : 'http://127.0.0.1:<%= connect.port %>/'
Not defining a host will mean your specs will be run from the local filesystem.

## options.template
Type: `String`
Default: `default`
Options: `default`, `requirejs`, `yourcustomtemplate.tmpl`
Type: `String` `Object`
Default: undefined

Specify a custom template to use when generating your Spec Runner. Templates are parsed as underscore templates and provided
Specify a custom template used to generate your Spec Runner. Templates are parsed as underscore templates and provided
the expanded list of files needed to build a specrunner.

You can specify an object with a `process` method that will be called as a template function.
See the [Template API Documentation](needs-wiki-link) for more details.

## options.templateOptions
Type: `Object`
Default: `{}`

These options will be passed to your template as an 'options' hash so that you can provide settings to your template.

## options.junit
Type: `Object`
Default: `{}`

Set `options.junit.path` to generate JUnit compatible XML from the task (for use in a CI system such as Jenkins).

Set `options.junit.consolidate` to consolidate the generated XML files so that there is one file per top level suite.

# Flags

Name: `build`
Expand All @@ -85,29 +91,3 @@ watch: {
}
}
```

# Template Options

## Default template

No specific options are expected or used.

## RequireJS template

### templateOptions.requirejs
Type: `String`

The path to requirejs if you need to specify an alternate version.

### templateOptions.loaderPlugin
Type: `String`

The loader plugin to prefix all loaded `src` files. This is useful for processing
your specs through the likes of CoffeeScript or TypeScript plugins. Keep in mind
you will need to specify the path to the plugin in the require config.

### templateOptions.requireConfig
Type: `Object`

This object is `JSON.stringify()`-ed into the template and passed into `require.config()`

4 changes: 2 additions & 2 deletions docs/jasmine-overview.md
Expand Up @@ -12,11 +12,11 @@ Run your tests on your local filesystem or via a server task like [grunt-contrib

## AMD Support

Includes a SpecRunner template customized for use with AMD modules and requirejs.
Supports AMD tests via the [grunt-template-jasmine-requirejs](https://github.com/jsoverson/grunt-template-jasmine-requirejs) module

## Customize your SpecRunner with your own template

Supply your own underscore template to automatically build your SpecRunner custom to your use.
Supply your templates that will be used to automatically build the SpecRunner.

## Example application usage

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -29,7 +29,8 @@
},
"dependencies": {
"grunt-lib-phantomjs": "~0.1.0",
"grunt": "~0.4.0"
"grunt": "~0.4.0",
"rimraf": "~2.0.3"
},
"devDependencies": {
"grunt-contrib-internal": "~0.1.1",
Expand Down

0 comments on commit 7fd976a

Please sign in to comment.