跳到主要內容

發表文章

目前顯示的是 4月, 2014的文章

mocha timeout 2000, 設定方式

mocha timeout 2000, 設定方式 目前測試架構採取 mocha, 常常會需要更改 mocha 的 timeout 時間,可以透過設定如下。 mocha 參數 透過參數的方式設定每次 mocha 要執行的時間。 mocha --timeout 15000 時間數字以毫秒計算。 mocha test case 設定 另外可以在 test case 裡面進行設定。 describe('...', function(){ this.timeout(15000); it('...', function(done){ setTimeout(15000); }); }); mochat 設定檔 可以在測試資料裡面設定一個 mocha.opts 檔案 ,設定大概如下, --require should --reporter dot --ui bdd 結語 mocha 提供許多完整的測試方案,對於不管是使用 TDD, BDD 的方式都可以適用,對於開發者來說,測試其實是一件很重要的事情,歡迎大家多測多健康 參考連結 http://visionmedia.github.io/mocha/#mocha.opts In mocha testing while calling asynchronous function how to avoid the timeout Error: timeout of 2000ms exceeded.

CoffeeScrpt node module compile and continous integration in Travis

CoffeeScrpt node module compile and continous integration in Travis 最近開始一直使用 coffeeScript 作為主要編輯程式,當我們在使用 Travis 的時候,會遇到許多問題,以下記錄一下設定方式。 npm 設定部分 經過查詢一下之後,發現 npm.org 這邊有一個設定方式 preinstall ,需要設定在 package.json 裡面。設定方式如下, "scripts": { "preinstall": "node_modules/.bin/cake build" }, preinstall 這個部分主要是用於,當使用執行 npm install ,在模組安裝之前會觸發 preinstall 裡面的指令。 這邊大家會發現,我們使用 node_modules 裡面的 .bin 目錄下程式進行編譯,因為在 node 模組中,只要模組有提供 cli 的模式,他都會存在 node_modules 底下,被搬移到 .bin 這個目錄中。所以我們都可以在 npm install 相依模組安裝完成後,進入到 node_modules/.bin 裡面找到程式指令。 travis 環境設定 可是如果在 travis 測試環境中,我們會發現,在開始編譯之前,我們是不會有 node_modules 這個模組安裝,因此我們需要增加 travis 的設定條件,讓他在進行任何事情之前,先行進行安裝 node_modules,這邊需要針對設定檔案 .travis.yml language: node_js node_js: - "0.10" before_script: ./node_modules/.bin/cake build before_install: - npm install coffee-script 這邊設定了 before_script, before_install 這兩個指令,將會在整個專案下載之前進行 npm install coffee-script, 安裝完成後,就會進行下載 project, 之後再進行 before_script

semver, node package.json, dependency module version operators

semver node package.json, dependency module version operators 之前沒有注意到這個問題,現在 node modules 越來越多,原來在 npm 裡面早就有進行相關的版本管理。可以透過這個頁面看到詳細的描述資訊。 The semantic versioner for npm 特別要介紹的部份是, ^ 字元與版本關係 ^ 表示可以進行兼容模式,當第一個非 0 數字被符合之後,就會此此版本安裝。當可安裝版本為 > 0.1.5 ,此時是會直接使用 0.1.5 這個版本進行安裝。 如果一開始使用非 0 數字為版本,就會變成兼容模式,會去尋找符合第一個數字的版本,其他小數字本版號視為可以兼容。 目前 npm install node_modules --save 會採用 ^ 這個符號。 ^0.1.3 := >=0.1.3-0 <0.2.0-0 "Compatible with 0.1.3". 0.x.x versions are special: the first non-zero component indicates potentially breaking changes, meaning the caret operator matches any version with the same first non-zero 另外一種版本 ^1.2.3 := >=1.2.3-0 <2.0.0-0 "Compatible with 1.2.3". When using caret operators, anything from the specified version (including prerelease) will be supported up to, but not including, the next major version (or its prereleases). 1.5.1 will satisfy ^1.2.3, while 1.2.2 and 2.0.0-beta will not. ~ 字元與版本關係 版本需要數字符合,例如底下的例子

[news] OpenSSL 嚴重錯誤問題

OpenSSL 嚴重錯誤問題 在今天 oepnssl 爆出嚴重安全性問題, openssl Heartbeat overflow issue 由 openssl 資訊提供,詳情可以透過 hearbleed 了解實際狀況。 主要狀況是因為在 TLS 的部份檢查驗證部分出錯,導致 openssl 有 memory leak 的問題,會讓原本用於加密的 private key 暴露,之後會讓 https 的原本加密的資訊,直接呈現於取得 private key 的使用者手中。 解法 請儘快升級 OpenSSL 1.0.1g , 進行 openssl 模組更新,修正此錯誤。 OpenSSL 1.0.2 版本也會同時修復此問題。 資訊 OpenSSL heartbleed 重大漏洞,全球網路加密傳輸安全拉警報 最新 OpenSSL 漏洞讓網路服務商「內心淌血」...

解決 jekyll 在 MacOS 遇到的問題,fixed jekyll install problem

fixed jekyll install problem 安裝 jekyll 的時候遇到一個問題, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h 環境 MacOS 解決方法 安裝 Xcode 開啟 Xcode Preferences > Downloads > Install Command Line Tools 接著重新安裝 jekyll (sudo) gem install jekyll 就可以順利完成