Skip to content

Commit 2bebccb

Browse files
committed
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`.
1 parent b9eb501 commit 2bebccb

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

app/index.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,34 @@ var Generator = module.exports = function Generator(args, options) {
5252
args: args
5353
});
5454

55-
this.hookFor('karma', {
56-
as: 'app',
57-
options: {
55+
this.on('end', function () {
56+
this.installDependencies({ skipInstall: this.options['skip-install'] });
57+
58+
var enabledComponents = [];
59+
60+
if (this.resourceModule) {
61+
enabledComponents.push('angular-resource/angular-resource.js');
62+
}
63+
64+
if (this.cookiesModule) {
65+
enabledComponents.push('angular-cookies/angular-cookies.js');
66+
}
67+
68+
if (this.sanitizeModule) {
69+
enabledComponents.push('angular-sanitize/angular-sanitize.js');
70+
}
71+
72+
this.invoke('karma:app', {
5873
options: {
5974
coffee: this.options.coffee,
6075
travis: true,
61-
'skip-install': this.options['skip-install']
62-
}
63-
}
64-
});
65-
66-
this.on('end', function () {
67-
this.installDependencies({ skipInstall: this.options['skip-install'] });
76+
'skip-install': this.options['skip-install'],
77+
components: [
78+
'angular/angular.js',
79+
'angular-mocks/angular-mocks.js'
80+
].concat(enabledComponents)
81+
}
82+
});
6883
});
6984

7085
this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"yeoman-generator": "~0.13.0"
2626
},
2727
"peerDependencies": {
28-
"generator-karma": "~0.5.0",
28+
"generator-karma": "~0.6.0",
2929
"yo": ">=1.0.0-rc.1.1"
3030
},
3131
"devDependencies": {

0 commit comments

Comments
 (0)