Created
July 22, 2014 22:54
-
-
Save hiroosak/3b2c05053502b4073024 to your computer and use it in GitHub Desktop.
テストランナーkarmaをとりあえず使ってみる方法 ref: http://qiita.com/taizo/items/04c80dcd2841cb1119a8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Foo = function() { | |
}; | |
Foo.prototype.sum = function(x, y) { | |
return x + y; | |
}; | |
Foo.prototype.div = function(x, y) { | |
return x / y; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Foo', function() { | |
it("2 plus 3 is 5", function() { | |
var foo = new Foo(); | |
expect(foo.sum(2,3)).toBe(5); | |
}); | |
it("10 divided 5 is 2", function() { | |
var foo = new Foo(); | |
expect(foo.div(10,5)).toBe(2); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install -g karma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ karma init | |
Which testing framework do you want to use ? | |
Press tab to list possible options. Enter to move to the next question. | |
> jasmine # 選択肢がある場合は、タブで切り替えが出来る |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ karma start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(config) { | |
config.set({ | |
basePath: '', | |
frameworks: ['jasmine'], | |
files: [ | |
'app.js', | |
'app_test.js' | |
], | |
reporters: ['progress'], | |
port: 9876, | |
colors: true, | |
logLevel: config.LOG_INFO, | |
autoWatch: true, | |
browsers: ['Chrome'], | |
singleRun: true | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment