Created
May 4, 2013 07:40
-
-
Save maiko-ampersand/5516679 to your computer and use it in GitHub Desktop.
grunt+jasmineな環境作成手順 ref: http://qiita.com/items/0811f788accd3651e04a
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 -v |
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
sudo npm install -g grunt-cli |
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
grunt watch |
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
Completed in 2.249s at Sat May 04 2013 16:33:33 GMT+0900 (JST) - Waiting...OK | |
>> File "src/js/sample.js" changed. | |
Running "jasmine:test" (jasmine) task | |
Testing jasmine specs via phantom | |
. | |
1 spec in 0.002s. | |
>> 0 failures | |
Done, without errors. |
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
sudo npm install grunt --save-dev |
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
sudo npm install grunt-contrib-watch --save-dev |
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
sudo npm install grunt-contrib-jasmine --save-dev |
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
Gruntfile.js | |
package.json | |
node_modules(自動作成されたフォルダ) | |
spec(任意作成したフォルダ・テストケースのjsを入れる) | |
src(任意作成したフォルダ・開発物を入れる) | |
└js(jsを入れる) |
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(grunt) { | |
grunt.initConfig({ | |
watch: { | |
// src/jsフォルダ以下のjs拡張子ファイルを対象に監視 | |
files: ['src/js/*.js'], | |
// 変更があったらタスクjasmineを実行 | |
tasks: ['jasmine'] | |
}, | |
jasmine: { | |
// プロパティ名はテストケース名 | |
sample: { | |
// このテストケースでテストするファイルの指定 | |
src: 'src/js/sample.js', | |
options: { | |
// テストケース | |
specs: 'spec/*Spec.js', | |
// ヘルパー | |
helpers: 'spec/*Helper.js' | |
} | |
} | |
} | |
}); | |
// gruntでjasmineを使う | |
grunt.loadNpmTasks('grunt-contrib-jasmine'); | |
// 変更したファイルを監視するためのwatch | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
}; |
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
{ | |
"name": "practis", | |
"devDependencies": { | |
"grunt": "~0.4.1", | |
"grunt-contrib-watch": "~0.4.0", | |
"grunt-contrib-jasmine": "~0.4.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
var sample = {}; | |
sample.test = function(param){ | |
return {say : function(){return 'say ' + param}} | |
} |
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("test case name", function() { | |
var foo; | |
beforeEach(function() { | |
foo = sample.test('hallo'); | |
}); | |
it("should say", function (){ | |
var say = foo.say('hallo'); | |
expect(say).toEqual("say hallo"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment