翻译于 2016/12/08 11:06
1 人 顶 此译文
New code and user testing tools and frameworks seem to pop up every day. Below is a varied list of code tools that accomplish various testing needs. Each one should be investigated to make sure it fits with your tech stack and technical needs.
Jasmine is a behaviour-driven development framework for testing JavaScript code. It doesn't depend on any other JavaScript frameworks and it doesn't require a DOM. However it does have a clean, obvious syntax so that you can easily write tests.
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.
每天都会产生新的代码、用户测试工具和框架。下面的列表列出了可以完成各种测试需求的代码工具。你应该调查研究一下,看这些工具是否适用于你的技术栈和技术需求。
Jasmine 是一个行为驱动的测试开发框架,用于对 JavaScript 代码进行测试。它不依赖其它任何 JavaScript 框架,也不需要 DOM。它的语法简洁、明确,写测试非常容易。
Mocha 是一个功能丰富的 JavaScript 测试框架,既运行于 Node.js 环境中,也可以运行于浏览器环境中。Mocha 以串行方式运行测试,能做出灵活而准确的报告,也能将测试中未捕捉的异常映射到正确的测试用例。
03. Chai
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
QUnit is a powerful, easy-to-use JavaScript unit testing framework. It's used by the jQuery, jQuery UI and jQuery Mobile projects and is capable of testing any generic JavaScript code.
Sinon.JS provides standalone test spies, stubs and mocks for JavaScript. It doesn't rely on dependencies, and works with any unit testing framework.
Chai 是个支持 BDD / TDD 的库,可用于 node 和浏览器,可配合任何 JavaScript 测试框架使用。
QUnit 是个功能强大又易于使用的 JavaScript 单元测试框架。jQuery、jQuery UI 和 jQuey Mobile 项目都使用这个框架,它能测试普通的 JavaScript 代码。
Sinon.JS 为 JavaScript 提供了独立的 spies、stubs 和 mocks [译者注:Spy、Stub 和 Mock 都是测试专用名词,Stub 常被翻译为桩,spies 是 Spy 的复数形式,是一种可以监视方法、调用和参数的技术]。它不依赖任何东西,可以配合任何单元测试框架工作。
Karma is a framework-agnostic test runner for connected browsers. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.
Selenium has a straightforward aim: to automate browsers. It is used primarily for automating web applications for testing purposes, but it can just as easily take care of web-based administrative tasks.
08. WebdriverIO
WebdriverIO lets users control a browser or a mobile application with just a few lines of code, making test code simple, concise and easy to read. The integrated test runner also lets you write asynchronous commands in a synchronous way so that you don’t need to care about how to handle a Promise to avoid racing conditions. Additionally it takes away all the cumbersome setup work and manages the Selenium session for you.
Nightwatch.js is an easy to use Node.js based End-to-End (E2E) testing solution for browser based apps and websites. It uses the powerful W3C WebDriver API to perform commands and assertions on DOM elements.
WebdriverIO 允许用户仅添加几行代码就可以控制浏览器或移动应用程序,使测试代码更简单、简洁、易读。集成的 TestRunner 同样允许你以同步的方式调用异步命令,这样你不需要关心如何处理 Promise 以避免竞态条件。此外,它取消了所有的繁琐的设置工作,并且会为您管理的 Selenium 会话。
Nightwatch.js 是一个易于使用的 Node.js,它是为基于浏览器的 app 和网站设计的终端到终端(E2E)的测试方法。它使用强大的 W3C WebDriver API ,用于在 DOM 元素上执行命令和断言。
PhantomCSS takes screenshots captured by CasperJS and compares them to baseline images using Resemble.js to test for rgb pixel differences. PhantomCSS then generates image diffs to help you find the cause.
PhantomFlow delivers UI testing with decision trees. It provides an experimental approach to UI testing, based on Decision Trees. A NodeJS wrapper for PhantomJS, CasperJS and PhantomCSS, PhantomFlow enables a fluent way of describing user flows in code whilst generating structured tree data for visualisation.
Percy provides iterative and fast feedback about visual changes, delivering what is calls continuous visual integration. It does this by running with a test suite, taking DOM snapshots, and uploading the, to the Percy service where they are rendered in a modern browser.
PhantomCSS 获得 CasperJS 捕获的屏幕截图,并使用 Resemble.js 将其与基准图进行对比,以测试 RGB 像素差异。 PhantomCSS 然后生成图像差异对比,用于帮助您找到原因。
PhantomFlow 使用决策树提供 UI 测试方案。针对 PhantomJS, CasperJS 和 PhantomCSS 的 NodeJS 包装器—— PhantomFlow 能够流畅地在代码中描述用户流程,同时生成用于可视化的结构化树数据。
Percy 提供关于视觉变化的迭代及快速反馈,带来了所谓的连续视觉集成。它是通过下面方式实现的:运行测试套件,获取 DOM 快照并上传到 Percy 服务,最终在浏览器中渲染之。