From 2bebccbdd15d177805440b6d1ec84cc38a2b4678 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Sat, 19 Oct 2013 15:25:30 +0100 Subject: [PATCH] fix(app): test setup in default configuration Since modules selected during the scaffolding process are now automatically added to app dependencies, test would fail because karma didn't have an option to load additional modules. With generator-karma 0.6 I added an option to load additional bower components which this generator now makes use of when calling `hookFor`. --- app/index.js | 35 +++++++++++++++++++++++++---------- package.json | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/index.js b/app/index.js index 3fac9b8..d1526ba 100644 --- a/app/index.js +++ b/app/index.js @@ -52,19 +52,34 @@ var Generator = module.exports = function Generator(args, options) { args: args }); - this.hookFor('karma', { - as: 'app', - options: { + this.on('end', function () { + this.installDependencies({ skipInstall: this.options['skip-install'] }); + + var enabledComponents = []; + + if (this.resourceModule) { + enabledComponents.push('angular-resource/angular-resource.js'); + } + + if (this.cookiesModule) { + enabledComponents.push('angular-cookies/angular-cookies.js'); + } + + if (this.sanitizeModule) { + enabledComponents.push('angular-sanitize/angular-sanitize.js'); + } + + this.invoke('karma:app', { options: { coffee: this.options.coffee, travis: true, - 'skip-install': this.options['skip-install'] - } - } - }); - - this.on('end', function () { - this.installDependencies({ skipInstall: this.options['skip-install'] }); + 'skip-install': this.options['skip-install'], + components: [ + 'angular/angular.js', + 'angular-mocks/angular-mocks.js' + ].concat(enabledComponents) + } + }); }); this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); diff --git a/package.json b/package.json index a0b2348..5f0484a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "yeoman-generator": "~0.13.0" }, "peerDependencies": { - "generator-karma": "~0.5.0", + "generator-karma": "~0.6.0", "yo": ">=1.0.0-rc.1.1" }, "devDependencies": {