[TOC]
除了單元測試,某些項目可能還會用到端對端測試(由于用的少,這里就簡單列一下常用的第三方框架,感興趣的可以自行了解)
1. `CasperJS`
2. `Protractor`
3. `Nightwatch.js`
4. `TestCafe`
5. `CodeceptJS`
6. Sinon
[Using Mocks for Testing in JavaScript With Jest (stackabuse.com)](https://stackabuse.com/using-mocks-for-testing-in-javascript-with-jes/#settingupjestinanodejsapplication)
# HTML-parser on Node.js
You can also take a look at x-ray:[https://github.com/lapwinglabs/x-ray](https://github.com/lapwinglabs/x-ray)
[playwright · GitHub Topics](https://github.com/topics/playwright)
If you want to build [DOM](http://en.wikipedia.org/wiki/Document_Object_Model)you can use[jsdom](https://github.com/tmpvar/jsdom).
There's also [cheerio](https://github.com/MatthewMueller/cheerio), it has the [jQuery](http://jquery.com/) interface and it's a lot faster than older versions of jsdom, although these days they are similar in performance.
You might wanna have a look at [htmlparser2](https://github.com/fb55/htmlparser2), which is a streaming parser, and according to its benchmark, it seems to be faster than others, and no DOM by default. It can also produce a DOM, as it is also bundled with a handler that creates a DOM. This is the parser that is used by cheerio.
[parse5](https://github.com/inikulin/parse5)also looks like a good solution. It's fairly active (11 days since the last commit as of this update), WHATWG-compliant, and is used in [jsdom](https://github.com/tmpvar/jsdom),[Angular](https://github.com/angular/angular), and [Polymer](https://github.com/Polymer/polymer).
And if you want to parse HTML for[web scraping](http://en.wikipedia.org/wiki/Web_scraping), you can use [YQL](http://developer.yahoo.com/yql/). There is a [node module](https://github.com/derek/node-yql) for it. YQL I think would be the best solution if your HTML is from a[static](http://en.wikipedia.org/wiki/Static_web_page)website, since you are relying on a service, not your own code and processing power. Though note that it won't work if the page is disallowed by the robot.txt of the website, YQL won't work with it.
If the website you're trying to scrape is [dynamic](http://en.wikipedia.org/wiki/Dynamic_web_page) then you should be using a [headless browser](https://en.wikipedia.org/wiki/Headless_browser) like [phantomjs](http://phantomjs.org/). Also have a look at [casperjs](http://casperjs.org/), if you're considering phantomjs. And you can control casperjs from node with [SpookyJS](https://github.com/WaterfallEngineering/SpookyJS).
Beside phantomjs there's [zombiejs](http://zombie.labnotes.org/). Unlike phantomjs that cannot be embedded in nodejs, zombiejs is just a node module.
There's a [nettuts+ toturial](http://net.tutsplus.com/tutorials/javascript-ajax/web-scraping-with-node-js/)for the latter solutions.
- 講解 Markdown
- 示例
- SVN
- Git筆記
- github 相關
- DESIGNER'S GUIDE TO DPI
- JS 模塊化
- CommonJS、AMD、CMD、UMD、ES6
- AMD
- RequrieJS
- r.js
- 模塊化打包
- 學習Chrome DevTools
- chrome://inspect
- Chrome DevTools 之 Elements
- Chrome DevTools 之 Console
- Chrome DevTools 之 Sources
- Chrome DevTools 之 Network
- Chrome DevTools 之 Memory
- Chrome DevTools 之 Performance
- Chrome DevTools 之 Resources
- Chrome DevTools 之 Security
- Chrome DevTools 之 Audits
- 技巧
- Node.js
- 基礎知識
- package.json 詳解
- corepack
- npm
- yarn
- pnpm
- yalc
- 庫處理
- Babel
- 相關庫
- 轉譯基礎
- 插件
- AST
- Rollup
- 基礎
- 插件
- Webpack
- 詳解配置
- 實現 loader
- webpack 進階
- plugin 用法
- 輔助工具
- 解答疑惑
- 開發工具集合
- 花樣百出的打包工具
- 紛雜的構建系統
- monorepo
- 前端工作流
- 爬蟲
- 測試篇
- 綜合
- Jest
- playwright
- Puppeteer
- cypress
- webdriverIO
- TestCafe
- 其他
- 工程開發
- gulp篇
- Building With Gulp
- Sass篇
- PostCSS篇
- combo服務
- 編碼規范檢查
- 前端優化
- 優化策略
- 高性能HTML5
- 瀏覽器端性能
- 前后端分離篇
- 分離部署
- API 文檔框架
- 項目開發環境
- 基于 JWT 的 Token 認證
- 扯皮時間
- 持續集成及后續服務
- 靜態服務器搭建
- mock與調試
- browserslist
- Project Starter
- Docker
- 文檔網站生成
- ddd