Skip to content

Commit 427b7f8

Browse files
committed
chore(config): run tests against multiple versions
Karma now has 3 test configs, for 1.0.8, 1.1.5, and 1.2.4. Running `grunt integrate` will test all 3. Should be merged with `default` task for Travis integration when all tests are pass against all 3 versions.
1 parent 92f092c commit 427b7f8

File tree

5 files changed

+116
-64
lines changed

5 files changed

+116
-64
lines changed

Gruntfile.js

+24-18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module.exports = function (grunt) {
33

44
require('load-grunt-tasks')(grunt);
5+
var files = require('./files').files;
56

67
// Project configuration.
78
grunt.initConfig({
@@ -28,19 +29,7 @@ module.exports = function (grunt) {
2829
footer: '})(window, window.angular);'
2930
},
3031
build: {
31-
src: [
32-
'src/common.js',
33-
'src/resolve.js',
34-
'src/templateFactory.js',
35-
'src/urlMatcherFactory.js',
36-
'src/urlRouter.js',
37-
'src/state.js',
38-
'src/view.js',
39-
'src/viewScroll.js',
40-
'src/viewDirective.js',
41-
'src/stateDirectives.js',
42-
'src/compat.js'
43-
],
32+
src: files.src,
4433
dest: '<%= builddir %>/<%= pkg.name %>.js'
4534
}
4635
},
@@ -80,14 +69,30 @@ module.exports = function (grunt) {
8069
},
8170
karma: {
8271
options: {
83-
configFile: 'config/karma.js'
72+
configFile: 'config/karma.js',
73+
singleRun: true,
74+
exclude: [],
75+
frameworks: ['jasmine'],
76+
reporters: 'dots', // 'dots' || 'progress'
77+
port: 8080,
78+
colors: true,
79+
autoWatch: false,
80+
autoWatchInterval: 0,
81+
browsers: [ grunt.option('browser') || 'PhantomJS' ]
8482
},
8583
unit: {
86-
singleRun: true
87-
},
88-
background: {
89-
background: true,
9084
browsers: [ grunt.option('browser') || 'PhantomJS' ]
85+
},
86+
debug: {
87+
singleRun: false,
88+
background: false,
89+
browsers: [ grunt.option('browser') || 'Chrome' ]
90+
},
91+
past: {
92+
configFile: 'config/karma-1.0.8.js',
93+
},
94+
unstable: {
95+
configFile: 'config/karma-1.1.5.js',
9196
}
9297
},
9398
changelog: {
@@ -109,6 +114,7 @@ module.exports = function (grunt) {
109114
}
110115
});
111116

117+
grunt.registerTask('integrate', ['build', 'jshint', 'karma:unit', 'karma:past', 'karma:unstable']);
112118
grunt.registerTask('default', ['build', 'jshint', 'karma:unit']);
113119
grunt.registerTask('build', 'Perform a normal build', ['concat', 'uglify']);
114120
grunt.registerTask('dist', 'Perform a clean build and generate documentation', ['clean', 'build', 'jsdoc']);

config/karma-1.0.8.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Karma configuration file
2+
module.exports = function (karma) {
3+
4+
var files = require('../files').files;
5+
6+
karma.set({
7+
// base path, that will be used to resolve files and exclude
8+
basePath: '..',
9+
10+
// list of files / patterns to load in the browser
11+
files: [].concat(files.angular('1.0.8'), files.testUtils, files.src, files.test),
12+
13+
// level of logging
14+
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
15+
logLevel: karma.LOG_DEBUG,
16+
17+
// Start these browsers, currently available:
18+
// - Chrome
19+
// - ChromeCanary
20+
// - Firefox
21+
// - Opera
22+
// - Safari
23+
// - PhantomJS
24+
browsers: [ 'PhantomJS' ]
25+
})
26+
};

config/karma-1.1.5.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Karma configuration file
2+
module.exports = function (karma) {
3+
4+
var files = require('../files').files;
5+
6+
karma.set({
7+
// base path, that will be used to resolve files and exclude
8+
basePath: '..',
9+
10+
// list of files / patterns to load in the browser
11+
files: [].concat(files.angular('1.1.5'), files.testUtils, files.src, files.test),
12+
13+
// level of logging
14+
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
15+
logLevel: karma.LOG_DEBUG,
16+
17+
// Start these browsers, currently available:
18+
// - Chrome
19+
// - ChromeCanary
20+
// - Firefox
21+
// - Opera
22+
// - Safari
23+
// - PhantomJS
24+
browsers: [ 'PhantomJS' ]
25+
})
26+
};

config/karma.js

+5-46
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,19 @@
1-
// Testacular configuration file
1+
// Karma configuration file
22
module.exports = function (karma) {
3+
4+
var files = require('../files').files;
5+
36
karma.set({
47
// base path, that will be used to resolve files and exclude
58
basePath: '..',
69

7-
frameworks: ['jasmine'],
8-
910
// list of files / patterns to load in the browser
10-
files: [
11-
'lib/angular-1.1.5.js',
12-
'test/lib/angular-mocks-1.1.5.js',
13-
'test/testUtils.js',
14-
15-
'src/common.js',
16-
'src/resolve.js',
17-
'src/templateFactory.js',
18-
'src/urlMatcherFactory.js',
19-
'src/urlRouter.js',
20-
'src/view.js',
21-
'src/state.js',
22-
'src/viewScroll.js',
23-
'src/viewDirective.js',
24-
'src/stateDirectives.js',
25-
'src/stateFilters.js',
26-
'src/compat.js',
27-
28-
'test/*Spec.js',
29-
// 'test/compat/matchers.js',
30-
// 'test/compat/*Spec.js',
31-
],
32-
33-
// list of files to exclude
34-
exclude: [],
35-
36-
// use dots reporter, as travis terminal does not support escaping sequences
37-
// possible values: 'dots' || 'progress'
38-
reporters: 'dots',
39-
40-
// these are default values, just to show available options
41-
42-
// web server port
43-
port: 8080,
44-
45-
// enable / disable colors in the output (reporters and logs)
46-
colors: true,
11+
files: [].concat(files.angular('1.2.4'), files.testUtils, files.src, files.test),
4712

4813
// level of logging
4914
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
5015
logLevel: karma.LOG_DEBUG,
5116

52-
// enable / disable watching file and executing tests whenever any file changes
53-
autoWatch: false,
54-
55-
// polling interval in ms (ignored on OS that support inotify)
56-
autoWatchInterval: 0,
57-
5817
// Start these browsers, currently available:
5918
// - Chrome
6019
// - ChromeCanary

files.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
routerFiles = {
2+
src: [
3+
'src/common.js',
4+
'src/resolve.js',
5+
'src/templateFactory.js',
6+
'src/urlMatcherFactory.js',
7+
'src/urlRouter.js',
8+
'src/state.js',
9+
'src/view.js',
10+
'src/view.js',
11+
'src/viewScroll.js',
12+
'src/viewDirective.js',
13+
'src/stateDirectives.js',
14+
'src/stateFilters.js',
15+
'src/compat.js',
16+
],
17+
testUtils: [
18+
'test/testUtils.js'
19+
],
20+
test: [
21+
'test/*Spec.js'
22+
// 'test/compat/matchers.js',
23+
// 'test/compat/*Spec.js',
24+
],
25+
angular: function(version) {
26+
return [
27+
'lib/angular-' + version + '/angular.js',
28+
'lib/angular-' + version + '/angular-mocks.js',
29+
];
30+
}
31+
};
32+
33+
if (exports) {
34+
exports.files = routerFiles;
35+
}

0 commit comments

Comments
 (0)