Jest和酶有什么区别?

What is the difference between Jest and enzyme?(Jest和酶有什么区别?)
本文介绍了Jest和酶有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我是单元测试的新手.我想测试 React 项目.当我开始使用 React 文档时,将酶称为测试实用程序,这对我来说有点模棱两可.

I'm new to Unit testing. I want to test React project. As I started with React documentation which refers to enzyme as test utility which is kind of ambiguous to me.

Jestenzyme有什么区别?

  • enzyme断言库还是任务运行器?
  • 我可以将 karmaJasmine 一起使用吗?
  • 测试 react-redux 项目的最佳方法是什么?
  • Is enzyme assertion library or task runner?
  • Can I use karma with Jasmine?
  • What is the best way to test a react-redux project?

推荐答案

Jest 是一个包含任务运行器、断言库和模拟支持的框架.这意味着它可以执行不同的单元测试用例,将其结果写入控制台或日志文件,创建模拟或验证所有断言.简而言之,它将执行测试.

Jest is a framework which includes a task runner, assertion library, and mocking support. This means it can execute different unit test cases, write its result in console or log files, create mocks, or verify all the assertions. In short, it will execute the test.

Enzyme 是一个为编写单元测试提供简单接口的库.为此,它封装了 React TestUtils、JSDOM 和 CheerIO 等包.React TestUtils 具有将 React 组件渲染到文档中并模拟事件的方法.JSDOM 是 DOM(文档对象模型)的 JavaScript 实现.DOM 表示 UI 组件的树结构.CheerIO 实现了 jQuery 核心的一个子集,用于查询 DOM.

Enzyme, on other hand, is a library that provides a simple interface for writing unit tests. For this purpose, it wraps packages such as React TestUtils, JSDOM and CheerIO. React TestUtils has methods to render a React component into a document and to simulate an event. JSDOM is a JavaScript implementation of the DOM (Document object model). The DOM represents the tree structure of UI components. CheerIO implements a subset of jQuery core and is used to query the DOM.

Enzyme 不是测试运行器.它没有自己的断言库.它只是提供了一组用于单元测试的 API.这就是它可以与 Jest 或任何其他任务运行程序集成的原因.

Enzyme is not a test runner. It doesn't have its own assertion library. It just provides a collection of APIs for unit testing. That's why it could be integrated with Jest or any other task runner.

是的,你可以在茉莉花上使用因果报应.

Yes, you can use karma with jasmine.

这篇关于Jest和酶有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)