Commit 262d9e2a authored by Nick Stenning's avatar Nick Stenning

Simplify karma.config.js by setting basePath

Set the base path for the karma test runner to h/static/scripts.

The only slight subtlety here is that client templates are now keyed by
their basename: loading them from above the base path results in the
paths being absolute when they get to ng-html2js-preprocessor, so
stripPrefix doesn't work.
parent 11d5266e
// Karma configuration // Karma configuration
// Generated on Mon Jul 14 2014 14:06:50 GMT+0200 (CEST) // Generated on Mon Jul 14 2014 14:06:50 GMT+0200 (CEST)
var path = require('path');
module.exports = function(config) { module.exports = function(config) {
config.set({ config.set({
// base path that will be used to resolve all patterns (eg. files, exclude) // base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '', basePath: 'h/static/scripts',
// frameworks to use // frameworks to use
...@@ -19,34 +20,34 @@ module.exports = function(config) { ...@@ -19,34 +20,34 @@ module.exports = function(config) {
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
// Application external deps // Application external deps
'h/static/scripts/vendor/jquery.js', 'vendor/jquery.js',
'h/static/scripts/vendor/angular.js', 'vendor/angular.js',
'h/static/scripts/vendor/angular-animate.js', 'vendor/angular-animate.js',
'h/static/scripts/vendor/angular-bootstrap.js', 'vendor/angular-bootstrap.js',
'h/static/scripts/vendor/angular-resource.js', 'vendor/angular-resource.js',
'h/static/scripts/vendor/angular-route.js', 'vendor/angular-route.js',
'h/static/scripts/vendor/angular-sanitize.js', 'vendor/angular-sanitize.js',
'h/static/scripts/vendor/ng-tags-input.js', 'vendor/ng-tags-input.js',
'h/static/scripts/vendor/annotator.js', 'vendor/annotator.js',
'h/static/scripts/vendor/polyfills/autofill-event.js', 'vendor/polyfills/autofill-event.js',
'h/static/scripts/vendor/polyfills/bind.js', 'vendor/polyfills/bind.js',
'h/static/scripts/vendor/katex/katex.js', 'vendor/katex/katex.js',
'h/static/scripts/vendor/moment-with-langs.js', 'vendor/moment-with-langs.js',
'h/static/scripts/vendor/jstz.js', 'vendor/jstz.js',
'h/static/scripts/vendor/moment-timezone.js', 'vendor/moment-timezone.js',
'h/static/scripts/vendor/moment-timezone-data.js', 'vendor/moment-timezone-data.js',
'h/static/scripts/vendor/polyfills/url.js', 'vendor/polyfills/url.js',
// Test deps // Test deps
'h/static/scripts/vendor/angular-mocks.js', 'vendor/angular-mocks.js',
'h/static/scripts/vendor/polyfills/promise.js', 'vendor/polyfills/promise.js',
'h/static/scripts/vendor/sinon.js', 'vendor/sinon.js',
'h/static/scripts/vendor/chai.js', 'vendor/chai.js',
'h/templates/client/*.html', '../../templates/client/*.html',
'h/static/scripts/test/bootstrap.coffee', 'test/bootstrap.coffee',
// Tests // Tests
'h/static/scripts/**/*-test.coffee' '**/*-test.coffee'
], ],
...@@ -57,14 +58,14 @@ module.exports = function(config) { ...@@ -57,14 +58,14 @@ module.exports = function(config) {
// strip templates of leading path // strip templates of leading path
ngHtml2JsPreprocessor: { ngHtml2JsPreprocessor: {
moduleName: 'h.templates', moduleName: 'h.templates',
stripPrefix: 'h/templates/client/' cacheIdFromPath: path.basename
}, },
// preprocess matching files before serving them to the browser // preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: { preprocessors: {
'**/*.coffee': ['browserify'], '**/*.coffee': ['browserify'],
'h/templates/client/*.html': ['ng-html2js'], '../../templates/client/*.html': ['ng-html2js'],
}, },
browserify: { browserify: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment