問題描述
我不確定是否將 Travis-CI 用于我的客戶端 JavaScript 庫,因為它在 Travis-CI 服務(wù)器上使用 NodeJ 進(jìn)行編譯.
I'm not sure to use Travis-CI for my client-side JavaScript library or not, because it compiles with NodeJs on Travis-CI servers.
我想知道這是一種將某種持續(xù)集成(例如 Travis-CI)用于客戶端庫的好方法嗎?
I want to know is this a good approach to use some kind of continuous integration such as Travis-CI for client-side libraries or not?
推薦答案
是的,當(dāng)然你應(yīng)該使用與客戶端庫的持續(xù)集成.
Yes of course you should use continous integration with client side libraries.
我個人使用 PhantomJS(無頭 webkit 瀏覽器),即 已經(jīng)安裝在 Travis-CI 中.我認(rèn)為這對于客戶端的東西來說是比 NodeJs 更好的選擇.
I personally use PhantomJS (headless webkit browser) which is already installed in Travis-CI. I think this is the better option for client-side stuff than NodeJs.
如果你使用 Grunt,它會變得更容易使用,你只需要一個簡單的 Gruntfile.js 文件,您在瀏覽器中運(yùn)行的測試(我使用 QUnit)和一個簡單的 .travis.yml
If you use Grunt, it gets even easier to use, all you need is a simple Gruntfile.js file, your tests that run in browser (I use QUnit), and a simple .travis.yml
Gruntfile.js
:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
qunit: {
files: ['test/index.html']
}
});
// Load plugin
grunt.loadNpmTasks('grunt-contrib-qunit');
// Task to run tests
grunt.registerTask('test', 'qunit');
};
.travis.yml
:
before_script:
- sudo npm install -g grunt
script: grunt test --verbose --force
您可以在我的一個項目中查看實際效果(GitHub 上的源代碼).
You can see it in action at one of my projects (source on GitHub).
這篇關(guān)于將 Travis-CI 用于客戶端 JavaScript 庫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!