Skip to content

Commit

Permalink
fix(app): test setup in default configuration
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
passy committed Oct 19, 2013
1 parent b9eb501 commit 2bebccb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 25 additions & 10 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 2bebccb

Please sign in to comment.