Skip to content

Instantly share code, notes, and snippets.

@hiroosak
Created July 22, 2014 22:54
Show Gist options
  • Save hiroosak/3b2c05053502b4073024 to your computer and use it in GitHub Desktop.
Save hiroosak/3b2c05053502b4073024 to your computer and use it in GitHub Desktop.
テストランナーkarmaをとりあえず使ってみる方法 ref: http://qiita.com/taizo/items/04c80dcd2841cb1119a8
var Foo = function() {
};
Foo.prototype.sum = function(x, y) {
return x + y;
};
Foo.prototype.div = function(x, y) {
return x / y;
};
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);
});
});
$ npm install -g karma
$ karma init
Which testing framework do you want to use ?
Press tab to list possible options. Enter to move to the next question.
> jasmine # 選択肢がある場合は、タブで切り替えが出来る
$ karma start
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