Skip to content

Commit

Permalink
Switch test coverage to use Istanbul
Browse files Browse the repository at this point in the history
closes #4644

- Switch from using blanket to istanbul
- Rename some test files for consistency (and so that they will run)
  • Loading branch information
ErisDS committed Apr 19, 2015
1 parent ede50f3 commit 41b0d9f
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -54,8 +54,9 @@ Session.vim
# Changelog, which is autogenerated, not committed
CHANGELOG.md

# Casper generated files
# Test generated files
/core/test/functional/*.png
/core/test/coverage

config.js
/core/client/config.js
Expand Down
43 changes: 28 additions & 15 deletions Gruntfile.js
Expand Up @@ -130,6 +130,7 @@ var _ = require('lodash'),
'core/server/**/*.js',
'core/shared/**/*.js',
'core/test/**/*.js',
'!core/test/coverage/**',
'!core/shared/vendor/**/*.js'
]
},
Expand Down Expand Up @@ -166,6 +167,7 @@ var _ = require('lodash'),
'core/server/**/*.js',
'core/shared/**/*.js',
'core/test/**/*.js',
'!core/test/coverage/**',
'!core/shared/vendor/**/*.js'
]
}
Expand Down Expand Up @@ -240,18 +242,35 @@ var _ = require('lodash'),
// #### All Route tests
routes: {
src: [
'core/test/functional/routes/**/*_test.js'
'core/test/functional/routes/**/*_spec.js'
]
},

// #### All Module tests
module: {
src: [
'core/test/functional/module/**/*_test.js'
'core/test/functional/module/**/*_spec.js'
]
}
},

// ### grunt-mocha-istanbul
// Configuration for the mocha test coverage generator
// `grunt coverage`.
mocha_istanbul: {
coverage: {
// TODO fix the timing/async & cleanup issues with the route and integration tests so that
// they can also have coverage generated for them & the order doesn't matter
src: ['core/test/integration', 'core/test/unit'],
options: {
mask: '**/*_spec.js',
coverageFolder: 'core/test/coverage',
mochaOptions: ['--timeout=15000'],
excludes: ['core/client/**']
}
}
},

// ### grunt-bg-shell
// Used to run ember-cli watch in the background
bgShell: {
Expand Down Expand Up @@ -312,13 +331,6 @@ var _ = require('lodash'),
}
},

// #### Generate coverage report
// See the `grunt test-coverage` task in the section on [Testing](#testing) for more information.
coverage: {
command: 'node ' + mochaPath + ' --timeout 15000 --reporter html-cov > coverage.html ' +
path.resolve(cwd + '/core/test/blanket_coverage.js')
},

shrinkwrap: {
command: 'npm shrinkwrap'
}
Expand All @@ -333,7 +345,7 @@ var _ = require('lodash'),
options: {
onlyUpdated: true,
exclude: 'node_modules,.git,.tmp,bower_components,content,*built,*test,*doc*,*vendor,' +
'config.js,coverage.html,.travis.yml,*.min.css,screen.css',
'config.js,.travis.yml,*.min.css,screen.css',
extras: ['fileSearch']
}
}
Expand Down Expand Up @@ -492,7 +504,7 @@ var _ = require('lodash'),
// * [Building assets](#building%20assets):
// `grunt init`, `grunt` & `grunt prod` or live reload with `grunt dev`
// * [Testing](#testing):
// `grunt validate`, the `grunt test-*` sub-tasks or generate a coverage report with `grunt test-coverage`.
// `grunt validate`, the `grunt test-*` sub-tasks or generate a coverage report with `grunt coverage`.

// ### Help
// Run `grunt help` on the commandline to get a print out of the available tasks and details of
Expand Down Expand Up @@ -660,7 +672,7 @@ var _ = require('lodash'),
// If you need to run an individual route test file, you can do so, providing you have a `config.js` file and
// mocha installed globally by using a command in the form:
//
// `NODE_ENV=testing mocha --timeout=15000 --ui=bdd --reporter=spec core/test/functional/routes/admin_test.js`
// `NODE_ENV=testing mocha --timeout=15000 --ui=bdd --reporter=spec core/test/functional/routes/admin_spec.js`
//
// Route tests are run with [mocha](http://mochajs.org/) using
// [should](https://github.com/visionmedia/should.js) and [supertest](https://github.com/visionmedia/supertest)
Expand Down Expand Up @@ -723,16 +735,17 @@ var _ = require('lodash'),
);

// ### Coverage
// `grunt test-coverage` will generate a report for the Unit and Integration Tests.
// `grunt coverage` will generate a report for the Unit Tests.
//
// This is not currently done as part of CI or any build, but is a tool we have available to keep an eye on how
// well the unit and integration tests are covering the code base.
// Ghost does not have a minimum coverage level - we're more interested in ensuring important and useful areas
// of the codebase are covered, than that the whole codebase is covered to a particular level.
//
// Key areas for coverage are: helpers and theme elements, apps / GDK, the api and model layers.
grunt.registerTask('test-coverage', 'Generate unit and integration (mocha) tests coverage report',
['test-setup', 'shell:coverage']

grunt.registerTask('coverage', 'Generate unit and integration (mocha) tests coverage report',
['test-setup', 'mocha_istanbul:coverage']
);

// #### Master Warning *(Utility Task)*
Expand Down
11 changes: 0 additions & 11 deletions core/test/blanket_coverage.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -72,7 +72,6 @@
"pg": "4.1.1"
},
"devDependencies": {
"blanket": "~1.1.6",
"bower": "~1.3.10",
"grunt": "~0.4.5",
"grunt-bg-shell": "^2.3.1",
Expand All @@ -87,6 +86,7 @@
"grunt-express-server": "~0.4.19",
"grunt-jscs": "~1.2.0",
"grunt-mocha-cli": "~1.11.0",
"grunt-mocha-istanbul": "2.4.0",
"grunt-shell": "~1.1.1",
"grunt-update-submodules": "~0.4.1",
"matchdep": "~0.3.0",
Expand Down

0 comments on commit 41b0d9f

Please sign in to comment.