Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a single spec with grunt-contrib-jasmine

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.

like image 840
Rob Kinyon Avatar asked Jul 15 '13 21:07

Rob Kinyon


2 Answers

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.

like image 78
glortho Avatar answered Nov 18 '22 04:11

glortho


Chris Wren has written a blog post on Advanced Grunt Tooling, under the section Running individual test specs, he lists an example which allows for naming the spec you would like to run from the command line.

like image 20
Steen Avatar answered Nov 18 '22 03:11

Steen