tdd.md - cccnqu/se106a GitHub Wiki
測試
單元測試
TDD/BDD 測試驅動開發
先寫測試案例,然後才寫被測試模組與函數。
Mocha -- 單元測試框架
- https://mochajs.org/
- 前端的 mocha 測試 -- http://callmenick.com/post/basic-front-end-testing-with-mocha-chai
- 阮一峰:测试框架 Mocha 实例教程
Chai -- TDD, BDD 的檢查器
SuperTest -- 前端測試框架
istanbul -- 涵蓋度測試
- https://istanbul.js.org/
- https://github.com/istanbuljs/nyc (the Istanbul command line interface)
- https://istanbul.js.org/docs/tutorials/mocha/ (說明如何用 nyc + mocha 進行涵蓋度測試)
debug -- 印除錯訊息與執行時間
測試爬蟲
講很多和測試有關的 Node.js 書: Node.js 实战心得
- superagent : http://visionmedia.github.io/superagent/
- 操控爬蟲
- cheerio : https://github.com/cheeriojs/cheerio
- Node.js 版的 jquery,可抓取網頁內欄位。
無顯示瀏覽器 (headless browser)
- http://phantomjs.org/
- https://github.com/GoogleChrome/puppeteer
- [Automating Google Chrome with Node.js](https://tutorialzine.com/2017/08/automating-google-chrome-with-node-js]
- Puppeteer初探--爬取并生成《ES6标准入门》PDF
- Puppeteer再探--自动把SF文章推荐到掘金
Puppeteer 的功能
- Generate screenshots and PDFs of pages.
- Crawl a SPA and generate pre-rendered content (i.e. "SSR").
- Scrape content from websites.
- Automate form submission, UI testing, keyboard input, etc.
- Create an up-to-date, automated testing environment. Run your tests directly in the latest version of Chrome using the latest JavaScript and browser features.
- Capture a timeline trace of your site to help diagnose performance issues.
Benchmark (花費時間報告,速度比較)
- https://github.com/bestiejs/benchmark.js
- http://jsperf.com/ (分享 benchmark)