Run a single spec with grunt-contrib-jasmine

gruntjs, jasmine, javascript

Solution

Somebody has done this for you with a `--filter` command line argument, though it hasn't been pulled into master yet:

https://github.com/gruntjs/grunt-contrib-jasmine/pull/70

filename

`grunt jasmine --filter=foo` will run spec files that have foo in their file name.

folder

`grunt jasmine --filter=/foo` will run spec files within folders that have foo* in their name.

wildcard

`grunt jasmine --filter=/*-bar` will run anything that is located in a folder *-bar

comma separated filters

`grunt jasmine --filter=foo,bar` will run spec files that have foo or bar in their file name.

flags with space

`grunt jasmine --filter="foo bar"` will run spec files that have foo bar in their file name.

`grunt jasmine --filter="/foo bar"` will run spec files within folders that have foo bar* in their name.

Problem

How would I, on the command-line, specify a single specfile to run when using grunt-contrib-jasmine? My jasmine section looks something like: ``` jasmine: { myapp: { src: [ 'src/base.js', 'src/**/*.js' ] }, options: { spec: [ 'spec/models/**/*.js', 'spec/views/**/*.js' ] } } ``` I just want to run the tests for `spec/models/file1.js`.

Original source