[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