Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Commit 27f262b

Browse files
committed
Fixed karma testing
1 parent e831164 commit 27f262b

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

Gruntfile.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,26 @@ module.exports = function (grunt) {
2626
src: ['lib/**/*.js']
2727
}
2828
},
29-
webpackScenario: _.object(_.map(scenarios, function(test){
30-
return [test, { src: ['test/scenarios/'+test+'/webpack.conf.js'] }];
31-
})),
32-
karma: _.object(_.map(scenarios, function(test){
33-
return [test, {
34-
configFile: path.resolve('test', 'scenarios', test, 'karma.conf.js'),
35-
logLevel: 'DEBUG',
36-
singleRun: true,
37-
}];
38-
})),
29+
webpackScenario: _.object(_.filter(_.map(scenarios, function(test){
30+
var confFile = path.resolve('test', 'scenarios', test, 'webpack.conf.js');
31+
if( grunt.file.exists(confFile) ){
32+
return [test, { src: [confFile] }];
33+
}else{
34+
return null;
35+
}
36+
}))),
37+
karma: _.object(_.filter(_.map(scenarios, function(test){
38+
var confFile = path.resolve('test', 'scenarios', test, 'karma.conf.js');
39+
if( grunt.file.exists(confFile) ){
40+
return [test, {
41+
configFile: confFile,
42+
logLevel: 'DEBUG',
43+
singleRun: true,
44+
}];
45+
}else{
46+
return null;
47+
}
48+
}))),
3949
watch: {
4050
gruntfile: {
4151
files: '<%= jshint.gruntfile.src %>',
@@ -53,7 +63,7 @@ module.exports = function (grunt) {
5363
});
5464

5565
// Default task.
56-
grunt.registerTask('default', ['jshint', 'webpackScenario']);
66+
grunt.registerTask('default', ['jshint', 'webpackScenario', 'karma']);
5767

5868

5969
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Simplest test
2-
angular.module('myModule', []);
2+
angular.module('main', []);

test/scenarios/basic-module/out/bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
function(module, exports, __webpack_require__) {
33

44
(function(angular) {
5-
(module.exports['myModule'] = angular.module('myModule', []));
5+
(module.exports['main'] = angular.module('main', []));
66
}.call(exports, __webpack_require__(1)))
77
},
88
function(module, exports, require) {

test/scenarios/basic-module/verify/in-browser-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe("basic-module", function(){
33

44
it('exports the angular module', function(){
55
var m = require('main');
6-
expect(m.name).toBe('main');
6+
expect(m.main.name).toBe('main');
77
});
88

99
});

0 commit comments

Comments
 (0)