Typography

活版印字


  • Home
  • Archive
  • Categories
  • Tags
  •  

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo

初探 cucumberjs

Posted at 2016-09-18 cucumberjs 

範例下載

不知道是不是官方有販售付費影片教學的關係,Cucumberjs 的資料真的少得可憐,只好照著在 Modern Web 2016 聽到講者的分享,弄出一個基本的 Sandbox。

建立第一個 feature

初始化專案

1
2
npm init -y
npm i cucumberjs chai -S

建立空的 features 資料夾

mkdir features

寫第一個 feature

vi features/bmi.feature

執行

cucumberjs

or

npm test

因為我們還沒開始寫 step,當然會測試失敗,但這步驟會產出 step 的 template,可以把它複制貼到 step 檔案中。

建立 feature 所許的 step

vi features/bmiStep.js

再次執行

cucumberjs

or

npm test

現在就成功囉

產生 html 報表

安裝 cucumber-html-report 模組

npm i cucumber-html-report -S

設定 cucumber-html-report 設定檔

vi reporter.js

輸出 cucumber-html-report 所需的 JSON 格式測試結果

cucumberjs -f json:cucumber_report.json

or

npm run report:createJson

將 JSON 格式測試結果,轉成 html 報表格式

node reporter

or

npm run report:createHtml

開啟 html 報表

npm run report

相關參照

  • cucumber-html-report

測試涵蓋率

安裝 istanbul 模組

npm i istanbul -S

執行

istanbul cover cucumberjs

or

npm run coverage

Share 

 Previous post: 初探 momentjs Next post: 初探 node db migrate 

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo