Skip to content

Commit a9b177f

Browse files
author
Philipp Alferov
committed
Setup initial testing environment
1 parent 24dfef9 commit a9b177f

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

gulpfile.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ var config = {
4040
dest: './docs/dist'
4141
}
4242
},
43+
tests: {
44+
karma: 'test/karma.conf.js'
45+
},
4346
// A flag attribute to switch modes.
4447
isProd: false
4548
};
@@ -209,6 +212,19 @@ gulp.task('release:tag', ['release:bump', 'release:commit', 'release:push'], fun
209212
});
210213
});
211214

215+
gulp.task('unit', function() {
216+
// Nonsensical source to fall back to files listed in karma.conf.js.
217+
// See https://github.com/lazd/gulp-karma/issues/9
218+
return gulp.src('./foobar')
219+
.pipe($.karma({
220+
configFile: config.tests.karma,
221+
action: 'run'
222+
}))
223+
.on('error', function(err) {
224+
throw err;
225+
});
226+
});
227+
212228
gulp.task('release:npm', ['release:bump', 'release:commit', 'release:push', 'release:tag'], function (done) {
213229
spawn('npm', ['publish'], { stdio: 'inherit' }).on('close', done);
214230
});

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
},
2525
"homepage": "https://github.com/alferov/angular-file-saver",
2626
"devDependencies": {
27+
"angular-mocks": "^1.4.5",
2728
"browser-filesaver": "^1.0.0",
2829
"browser-sync": "^2.8.2",
2930
"browserify": "^11.0.1",
@@ -33,13 +34,19 @@
3334
"gulp-gh-pages": "^0.5.2",
3435
"gulp-git": "^1.2.4",
3536
"gulp-if": "^1.2.5",
37+
"gulp-karma": "0.0.4",
3638
"gulp-load-plugins": "^0.10.0",
3739
"gulp-plumber": "^1.0.1",
3840
"gulp-rename": "^1.2.2",
3941
"gulp-size": "^1.3.0",
4042
"gulp-uglify": "^1.2.0",
4143
"gulp-util": "^3.0.6",
4244
"husky": "^0.9.3",
45+
"jasmine-core": "^2.3.4",
46+
"karma": "^0.13.9",
47+
"karma-browserify": "^4.3.0",
48+
"karma-chrome-launcher": "^0.2.0",
49+
"karma-jasmine": "^0.3.6",
4350
"run-sequence": "^1.1.2",
4451
"vinyl-buffer": "^1.0.0",
4552
"vinyl-source-stream": "^1.1.0",

test/angular-file-saver.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
describe('Angular', function() {
4+
5+
it('should exist', function() {
6+
expect(angular).toBeDefined();
7+
});
8+
9+
});

test/karma.conf.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
module.exports = function(config) {
4+
config.set({
5+
basePath: '../',
6+
frameworks: ['jasmine', 'browserify'],
7+
preprocessors: {
8+
'src/**/*.js': ['browserify']
9+
},
10+
browsers: ['Chrome'],
11+
reporters: ['progress'],
12+
autoWatch: true,
13+
browserify: {
14+
debug: true,
15+
transform: []
16+
},
17+
proxies: {
18+
'/': 'http://localhost:9876/'
19+
},
20+
urlRoot: '/__karma__/',
21+
files: [
22+
'./node_modules/angular/angular.js',
23+
'./node_modules/angular-mocks/angular-mocks.js',
24+
'./src/angular-file-saver.js',
25+
// Test files
26+
'test/**/*.js'
27+
]
28+
});
29+
};

0 commit comments

Comments
 (0)