mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
Switch test coverage to use Istanbul
closes #4644 - Switch from using blanket to istanbul - Rename some test files for consistency (and so that they will run)
This commit is contained in:
parent
ede50f38a3
commit
6d04ead9f2
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
||||
|
43
Gruntfile.js
43
Gruntfile.js
@ -130,6 +130,7 @@ var _ = require('lodash'),
|
||||
'core/server/**/*.js',
|
||||
'core/shared/**/*.js',
|
||||
'core/test/**/*.js',
|
||||
'!core/test/coverage/**',
|
||||
'!core/shared/vendor/**/*.js'
|
||||
]
|
||||
},
|
||||
@ -166,6 +167,7 @@ var _ = require('lodash'),
|
||||
'core/server/**/*.js',
|
||||
'core/shared/**/*.js',
|
||||
'core/test/**/*.js',
|
||||
'!core/test/coverage/**',
|
||||
'!core/shared/vendor/**/*.js'
|
||||
]
|
||||
}
|
||||
@ -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: {
|
||||
@ -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'
|
||||
}
|
||||
@ -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']
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
@ -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)
|
||||
@ -723,7 +735,7 @@ 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.
|
||||
@ -731,8 +743,9 @@ var _ = require('lodash'),
|
||||
// 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)*
|
||||
|
@ -1,11 +0,0 @@
|
||||
// Posts
|
||||
/*jshint unused:false */
|
||||
var blanket = require('blanket')({
|
||||
pattern: ['/core/server/', '/core/client/', '/core/shared/'],
|
||||
'data-cover-only': ['/core/server/', '/core/client/', '/core/shared/']
|
||||
}),
|
||||
requireDir = require('require-dir');
|
||||
|
||||
requireDir('./unit');
|
||||
requireDir('./integration');
|
||||
requireDir('./functional/routes');
|
@ -134,7 +134,7 @@ describe('Admin Routing', function () {
|
||||
it('should block admin access over non-HTTPS', function (done) {
|
||||
request.get('/ghost/')
|
||||
.expect(403)
|
||||
.end(done);
|
||||
.end(doEnd(done));
|
||||
});
|
||||
|
||||
it('should allow admin access over HTTPS', function (done) {
|
||||
@ -173,14 +173,14 @@ describe('Admin Routing', function () {
|
||||
request.get('/ghost/')
|
||||
.expect('Location', /^https:\/\/localhost\/ghost\//)
|
||||
.expect(301)
|
||||
.end(done);
|
||||
.end(doEnd(done));
|
||||
});
|
||||
|
||||
it('should allow admin access over HTTPS', function (done) {
|
||||
request.get('/ghost/setup/')
|
||||
.set('X-Forwarded-Proto', 'https')
|
||||
.expect(200)
|
||||
.end(done);
|
||||
.end(doEnd(done));
|
||||
});
|
||||
});
|
||||
|
@ -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",
|
||||
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user