1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-03 17:59:28 +02:00

Introducing unit testing with Karma + Jasmine.

This commit is contained in:
Gunther Brunner 2014-08-19 20:20:18 +09:00
parent 0753ac4730
commit b2a354dd84
3 changed files with 26 additions and 1 deletions

View file

@ -47,5 +47,8 @@
"angular": "~1.3.0-beta.18",
"angular-sanitize": "~1.3.0-beta.18",
"bootstrap": "~3.2.0"
},
"devDependencies": {
"angular-mocks": "~1.2.22"
}
}

View file

@ -10,7 +10,11 @@ var gettext = require('gulp-angular-gettext')
var jade = require('gulp-jade')
var clean = require('gulp-clean')
var protractor = require("gulp-protractor")
var protractorConfig = require('./res/test/protractor.conf.js')
var karma = require('karma').server
var karmaConfig = require('./res/test/karma.conf.js')
var stream = require('stream')
var _ = require('lodash')
gulp.task('jshint', function () {
@ -41,13 +45,21 @@ gulp.task('lint', ['jshint', 'jsonlint'])
gulp.task('test', ['lint', 'protractor'])
gulp.task('build', ['translate', 'webpack:build'])
gulp.task('karma', function (done) {
karma.start(_.assign({}, karmaConfig, {singleRun: true}), done)
})
gulp.task('karma_watch', function (done) {
karma.start(karmaConfig, done)
})
gulp.task('webdriver_update', protractor.webdriver_update)
gulp.task('webdriver_standalone', protractor.webdriver_standalone)
gulp.task('protractor', ['webdriver_update'], function (callback) {
gulp.src(["./res/test/**/*.js"])
.pipe(protractor.protractor({
configFile: './res/test/protractor.conf.js'
configFile: protractorConfig
}))
.on('error', function (e) {
console.log(e)

10
res/app/hello-test.js Normal file
View file

@ -0,0 +1,10 @@
describe('greeter', function () {
function greet(str) {
return 'Helloaw, ' + str
}
it('should say Hello to the World', function () {
expect(greet('World')).toEqual('Hello, World!')
})
})