diff --git a/content/docs/addons-test-utils.md b/content/docs/addons-test-utils.md index d269eaa73..06690c885 100644 --- a/content/docs/addons-test-utils.md +++ b/content/docs/addons-test-utils.md @@ -1,27 +1,27 @@ --- id: test-utils -title: Test Utilities +title: ابزارهای تست permalink: docs/test-utils.html layout: docs category: Reference --- -**Importing** +**ایمپورت کردن** ```javascript import ReactTestUtils from 'react-dom/test-utils'; // ES6 var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm ``` -## Overview {#overview} +## بررسی اجمالی {#overview} -`ReactTestUtils` makes it easy to test React components in the testing framework of your choice. At Facebook we use [Jest](https://facebook.github.io/jest/) for painless JavaScript testing. Learn how to get started with Jest through the Jest website's [React Tutorial](https://jestjs.io/docs/tutorial-react). +`ReactTestUtils` عملیات تست کامپوننتهای ریاکت را در فریموورک موردنظرتان ساده میکند. ما در فیسبوک از [Jest](https://facebook.github.io/jest/) برای تست کردن جاوااسکریپتی بدون دردسر استفاده میکنیم. برای اینکه یاد بگیرید از کجا شروع کنید از [React Tutorial](https://jestjs.io/docs/tutorial-react) سایت Jest استفاده نمایید. -> Note: +> نکته: > -> We recommend using [React Testing Library](https://testing-library.com/react) which is designed to enable and encourage writing tests that use your components as the end users do. +> ما استفاده از [React Testing Library](https://testing-library.com/react) را پیشنهاد میکنیم، از آنجا که طراحی آن با هدف قادر ساختن و تشویق شما به نوشتن تست به گونهای است که کاربر نهایی کامپوننت شما را استفاده میکند. > -> Alternatively, Airbnb has released a testing utility called [Enzyme](https://airbnb.io/enzyme/), which makes it easy to assert, manipulate, and traverse your React Components' output. +> به عنوان جایگزین، Airbnb یک ابزار تست به نام [Enzyme](https://airbnb.io/enzyme/) منتشر کردهاست که بررسی، دستکاری و ارزیابی خروجی کامپوننتهای ریاکت شما را ساده میکند. - [`act()`](#act) - [`mockComponent()`](#mockcomponent) @@ -40,17 +40,17 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm - [`renderIntoDocument()`](#renderintodocument) - [`Simulate`](#simulate) -## Reference {#reference} +## مرجع {#reference} ### `act()` {#act} -To prepare a component for assertions, wrap the code rendering it and performing updates inside an `act()` call. This makes your test run closer to how React works in the browser. +برای آمادهسازی یک کامپوننت برای اثبات، کدی که آن را رندر و بهروز رسانی میکند را درون یک فراخوانی `act()` قرار دهید. اینکار باعث میشود تست شما به روش کارکرد ریاکت در مرورگر نزدیکتر شود. ->Note +>نکته > ->If you use `react-test-renderer`, it also provides an `act` export that behaves the same way. +>اگر از `react-test-renderer` استفاده میکنید، یک خروجی `act` که به همین شکل رفتار میکند برایتان فراهم میکند. -For example, let's say we have this `Counter` component: +برای مثال، اجازه دهید بگوییم این کامپوننت `Counter` را داریم: ```js class Counter extends React.Component { @@ -83,7 +83,7 @@ class Counter extends React.Component { } ``` -Here is how we can test it: +به این شکل آن را تست میکنیم: ```js{3,20-22,29-31} import React from 'react'; @@ -122,9 +122,9 @@ it('can render and update a counter', () => { }); ``` -- Don't forget that dispatching DOM events only works when the DOM container is added to the `document`. You can use a library like [React Testing Library](https://testing-library.com/react) to reduce the boilerplate code. +- فراموش نکنید که توضیع (dispatch) رویدادهای DOM تنها زمانی که DOM container به `document` اضافه شدهباشد کار میکند. شما میتوانید از یک کتابخانه مانند [React Testing Library](https://testing-library.com/react) برای کاهش کدهای تکراری (boilerplate) استفاده کنید. -- The [`recipes`](/docs/testing-recipes.html) document contains more details on how `act()` behaves, with examples and usage. +- سند [دستورالعملها](/docs/testing-recipes.html) شامل اطلاعات بیشتری در مورد چگونگی رفتار `act()`، با مثالها و کاربردها میباشد. * * * @@ -137,11 +137,11 @@ mockComponent( ) ``` -Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `