日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

react jest测试_如何使用React测试库和Jest开始测试React应用

發(fā)布時間:2023/11/29 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 react jest测试_如何使用React测试库和Jest开始测试React应用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

react jest測試

Testing is often seen as a tedious process. It's extra code you have to write, and in some cases, to be honest, it's not needed. But every developer should know at least the basics of testing. It increases confidence in the products they build, and for most companies, it's a requirement.

測試通常被視為乏味的過程。 這是您必須編寫的額外代碼,在某些情況下,老實說,它不是必需的。 但是,每個開發(fā)人員都應(yīng)該至少了解測試的基礎(chǔ)知識。 它提高了他們所制造產(chǎn)品的信心,對于大多數(shù)公司而言,這是必需的。

In the React world, there is an amazing library called the react-testing-library which helps you test your React Apps more efficiently. You use it with Jest.

在React世界中,有一個了不起的庫,稱為react-testing-library ,可幫助您更有效地測試React Apps。 您將其與Jest一起使用。

In this article, we will see the 8 simple steps you can take to start testing your React Apps like a boss.

在本文中,我們將看到您可以像執(zhí)行老板一樣開始測試React Apps的8個簡單步驟。

  • Prerequisites

    先決條件

  • Basics

    基本

  • What is React Testing Library?

    什么是React Testing庫?

  • 1. How to create a test snapshot?

    1.如何創(chuàng)建測試快照?

  • 2. Testing DOM elements

    2.測試DOM元素

  • 3. Testing events

    3.測試事件

  • 4. Testing asynchronous actions

    4.測試異步動作

  • 5. Testing React Redux

    5.測試React Redux

  • 6. Testing React Context

    6.測試React上下文

  • 7. Testing React Router

    7.測試React Router

  • 8. Testing HTTP Request

    8.測試HTTP請求

  • Final Thoughts

    最后的想法

  • Next Steps

    下一步

先決條件 (Prerequisites)

This tutorial assumes that you have at least a basic understanding of React. I will focus only on the testing part.

本教程假定您至少對React有基本的了解。 我將只關(guān)注測試部分。

And to follow along, you have to clone the project by running in your terminal:

接下來,您必須通過在終端中運行來克隆項目:

git clone https://github.com/ibrahima92/prep-react-testing-library-guide

Next, run:

接下來,運行:

yarn

Or, if you use NPM:

或者,如果您使用NPM:

npm install

And that's it! Now let's dive into some basics.

就是這樣! 現(xiàn)在讓我們深入一些基礎(chǔ)知識。

基本 (Basics)

Some key things will be used a lot in this article, and understanding their role can help you with your understanding.

本文將大量使用一些關(guān)鍵內(nèi)容,了解它們的作用可以幫助您理解。

it or test: describes the test itself. It takes as parameters the name of the test and a function that holds the tests.

it or test :描述測試本身。 它以測試名稱和保存測試的函數(shù)為參數(shù)。

expect: the condition that the test needs to pass. It will compare the received parameter to a matcher.

expect :測試需要通過的條件。 它將接收到的參數(shù)與匹配器進(jìn)行比較。

a matcher: a function that is applied to the expected condition.

a matcher :應(yīng)用于預(yù)期條件的功能。

render: the method used to render a given component.

render :用于呈現(xiàn)給定組件的方法。

import React from 'react' import {render} from '@testing-library/react' import App from './App'it('should take a snapshot', () => {const { asFragment } = render(<App />)expect(asFragment(<App />)).toMatchSnapshot()}) });

As you can see, we describe the test with it, then, use render to display the App component and expect that asFragment(<App />) matches toMatchSnapshot() (the matcher provided by jest-dom).

如您所見,我們使用it描述測試,然后使用render顯示App組件,并期望asFragment(<App />)與toMatchSnapshot()匹配(由jest-dom提供的匹配器)。

By the way, the render method returns several methods we can use to test our features. We also used destructuring to get the method.

順便說一句, render方法返回了幾種我們可以用來測試功能的方法。 我們還使用了分解來獲取方法。

That being said, let's move on and learn more about the React Testing Library in the next section.

話雖如此,讓我們繼續(xù)并在下一節(jié)中進(jìn)一步了解React測試庫。

什么是React Testing庫? (What is the React Testing Library?)

The React Testing Library is a very light-weight package created by Kent C. Dodds. It's a replacement for Enzyme and provides light utility functions on top of react-dom and react-dom/test-utils.

React Testing庫是由Kent C. Dodds創(chuàng)建的非常輕量級的軟件包。 它是Enzyme的替代品,并在react-dom和react-dom/test-utils之上提供了輕量級的實用程序功能。

The React Testing Library is a DOM testing library, which means that instead of dealing with instances of rendered React components, it handles DOM elements and how they behave in front of real users.

React Testing庫是一個DOM測試庫,這意味著它不處理渲染的React組件實例,而是處理DOM元素以及它們在實際用戶面前的行為。

It's a great library, it's (relatively) easy to start using, and it encourages good testing practices. Note – you can also use it without Jest.

這是一個很棒的庫,(相對)易于使用,并且鼓勵良好的測試實踐。 注意–您也可以在沒有Jest的情況下使用它。

"The more your tests resemble the way your software is used, the more confidence they can give you."

“您的測試越像軟件使用方式,就越能給您信心。”

So, let's start using it in the next section. By the way, you don't need to install any packages, since create-react-app comes with the library and its dependencies.

因此,讓我們在下一部分中開始使用它。 順便說一句,您不需要安裝任何軟件包,因為該庫及其依賴項附帶了create-react-app 。

1.如何創(chuàng)建測試快照 (1. How to create a test snapshot)

A snapshot, as the name suggests, allows us to save the snapshot of a given component. It helps a lot when you update or do some refactoring, and want to get or compare the changes.

顧名思義,快照使我們可以保存給定組件的快照。 當(dāng)您更新或進(jìn)行一些重構(gòu),并希望獲取或比較更改時,它會很有幫助。

Now, let's take a snapshot of the App.js file.

現(xiàn)在,讓我們對App.js文件進(jìn)行快照。

  • App.test.js

    App.test.js

import React from 'react' import {render, cleanup} from '@testing-library/react' import App from './App'afterEach(cleanup)it('should take a snapshot', () => {const { asFragment } = render(<App />)expect(asFragment(<App />)).toMatchSnapshot()}) });

To take a snapshot, we first have to import render and cleanup. These two methods will be used a lot throughout this article.

要拍攝快照,我們首先必須導(dǎo)入render和cleanup 。 在本文中,將經(jīng)常使用這兩種方法。

render, as you might guess, helps to render a React component. And cleanup is passed as a parameter to afterEach to just clean up everything after each test to avoid memory leaks.

render ,您可能已經(jīng)猜到,有助于呈現(xiàn)一個作出React的組成部分。 并且將cleanup作為參數(shù)傳遞給afterEach以便在每次測試后清除所有內(nèi)容,以避免內(nèi)存泄漏。

Next, we can render the App component with render and get back asFragment as a returned value from the method. And finally, make sure that the fragment of the App component matches the snapshot.

接下來,我們可以渲染的應(yīng)用組件render ,并取回asFragment從方法的返回值。 最后,確保App組件的片段與快照匹配。

Now, to run the test, open your terminal and navigate to the root of the project and run the following command:

現(xiàn)在,要運行測試,請打開終端并導(dǎo)航到項目的根目錄,然后運行以下命令:

yarn test

Or, if you use npm:

或者,如果您使用npm:

npm test

As a result, it will create a new folder __snapshots__ and a file App.test.js.snap in the src which will look like this:

結(jié)果,它將在src創(chuàng)建一個新文件夾__snapshots__和一個App.test.js.snap文件,如下所示:

  • App.test.js.snap

    App.test.js.snap

// Jest Snapshot v1, https://goo.gl/fbAQLPexports[`Take a snapshot should take a snapshot 1`] = ` <DocumentFragment><div class="App"><h1>Testing</h1></div> </DocumentFragment> `;

And if you make another change in App.js, the test will fail, because the snapshot will no longer match the condition. To make it passes, just press u to update it. And you'll have the updated snapshot in App.test.js.snap.

而且,如果您在App.js進(jìn)行其他更改,則測試將失敗,因為快照將不再符合條件。 要使其通過,只需按u即可對其進(jìn)行更新。 并且您將在App.test.js.snap擁有更新的快照。

Now, let's move on and start testing our elements.

現(xiàn)在,讓我們繼續(xù)并開始測試我們的元素。

2.測試DOM元素 (2. Testing DOM elements)

To test our DOM elements, we first have to look at the TestElements.js file.

為了測試我們的DOM元素,我們首先必須查看TestElements.js文件。

  • TestElements.js

    TestElements.js

import React from 'react'const TestElements = () => {const [counter, setCounter] = React.useState(0)return (<><h1 data-testid="counter">{ counter }</h1><button data-testid="button-up" onClick={() => setCounter(counter + 1)}> Up</button><button disabled data-testid="button-down" onClick={() => setCounter(counter - 1)}>Down</button></>)}export default TestElements

Here, the only thing you have to retain is data-testid. It will be used to select these elements from the test file. Now, let's write the unit test:

在這里,您唯一需要保留的就是data-testid 。 它將用于從測試文件中選擇這些元素。 現(xiàn)在,讓我們編寫單元測試:

Test if the counter is equal to 0:

測試計數(shù)器是否等于0:

TestElements.test.js

TestElements.test.js

import React from 'react'; import { render, cleanup } from '@testing-library/react'; import TestElements from './TestElements'afterEach(cleanup);it('should equal to 0', () => {const { getByTestId } = render(<TestElements />); expect(getByTestId('counter')).toHaveTextContent(0)});

As you can see, the syntax is quite similar to the previous test. The only difference is that we use getByTestId to select the necessary elements (remember the data-testid) and check if it passed the test. In others words, we check if the text content <h1 data-testid="counter">{ counter }</h1> is equal to 0.

如您所見,語法與先前的測試非常相似。 唯一的區(qū)別是,我們使用getByTestId選擇必要的元素(記住data-testid )并檢查其是否通過了測試。 換句話說,我們檢查文本內(nèi)容<h1 data-testid="counter">{ counter }</h1>是否等于0。

Test if the buttons are enabled or disabled:

測試按鈕是啟用還是禁用:

TestElements.test.js (add the following code block to the file)

TestElements.test.js (將以下代碼塊添加到文件中)

it('should be enabled', () => {const { getByTestId } = render(<TestElements />);expect(getByTestId('button-up')).not.toHaveAttribute('disabled')});it('should be disabled', () => {const { getByTestId } = render(<TestElements />); expect(getByTestId('button-down')).toBeDisabled()});

Here, as usual, we use getByTestId to select elements and check for the first test if the button has a disabled attribute. And for the second, if the button is disabled or not.

在這里,與往常一樣,我們使用getByTestId選擇元素并檢查按鈕是否具有disabled屬性的第一次測試。 第二,按鈕是否被禁用。

And if you save the file or run again in your terminal yarn test, the test will pass.

并且,如果您保存文件或在終端yarn test再次運行,該測試將通過。

Congrats! Your first test has passed!

恭喜! 您的第一個測試已通過!

Now, let's learn how to test an event in the next section.

現(xiàn)在,讓我們在下一部分中學(xué)習(xí)如何測試事件。

3.測試事件 (3. Testing events)

Before writing our unit tests, let's first check what the TestEvents.js looks like.

在編寫單元測試之前,讓我們首先檢查一下TestEvents.js外觀。

  • TestEvents.js

    TestEvents.js

import React from 'react'const TestEvents = () => {const [counter, setCounter] = React.useState(0)return (<><h1 data-testid="counter">{ counter }</h1><button data-testid="button-up" onClick={() => setCounter(counter + 1)}> Up</button><button data-testid="button-down" onClick={() => setCounter(counter - 1)}>Down</button></>)}export default TestEvents

Now, let's write the tests.

現(xiàn)在,讓我們編寫測試。

Test if the counter increments and decrements correctly when we click on buttons:

單擊按鈕時,測試計數(shù)器是否正確遞增和遞減:

TestEvents.test.js

TestEvents.test.js

import React from 'react'; import { render, cleanup, fireEvent } from '@testing-library/react'; import TestEvents from './TestEvents'afterEach(cleanup);it('increments counter', () => {const { getByTestId } = render(<TestEvents />); fireEvent.click(getByTestId('button-up'))expect(getByTestId('counter')).toHaveTextContent('1')});it('decrements counter', () => {const { getByTestId } = render(<TestEvents />); fireEvent.click(getByTestId('button-down'))expect(getByTestId('counter')).toHaveTextContent('-1')});

As you can see, these two tests are very similar except the expected text content.

如您所見,除了預(yù)期的文本內(nèi)容之外,這兩個測試非常相似。

The first test fires a click event with fireEvent.click() to check if the counter increments to 1 when the button is clicked.

第一個測試使用fireEvent.click()觸發(fā)click事件,以檢查單擊按鈕時計數(shù)器是否增加為1。

And the second one checks if the counter decrements to -1 when the button is clicked.

第二個檢查單擊按鈕時計數(shù)器是否遞減到-1。

fireEvent has several methods you can use to test events, so feel free to dive into the documentation to learn more.

fireEvent有幾種可用于測試事件的方法,因此請隨時閱讀文檔以了解更多信息。

Now that we know how to test events, let's move on and learn in the next section how to deal with asynchronous actions.

現(xiàn)在我們知道了如何測試事件,讓我們繼續(xù)學(xué)習(xí)下一節(jié)如何處理異步操作。

4.測試異步動作 (4. Testing asynchronous actions)

An asynchronous action is something that can take time to complete. It can be an HTTP request, a timer, and so on.

異步操作需要花費一些時間才能完成。 它可以是HTTP請求,計時器等。

Now, let's check the TestAsync.js file.

現(xiàn)在,讓我們檢查一下TestAsync.js文件。

  • TestAsync.js

    TestAsync.js

import React from 'react'const TestAsync = () => {const [counter, setCounter] = React.useState(0)const delayCount = () => (setTimeout(() => {setCounter(counter + 1)}, 500))return (<><h1 data-testid="counter">{ counter }</h1><button data-testid="button-up" onClick={delayCount}> Up</button><button data-testid="button-down" onClick={() => setCounter(counter - 1)}>Down</button></>)}export default TestAsync

Here, we use setTimeout() to delay the incrementing event by 0.5s.

在這里,我們使用setTimeout()將增量事件延遲0.5s。

Test if the counter is incremented after 0.5s:

測試計數(shù)器是否在0.5s后遞增:

TestAsync.test.js

TestAsync.test.js

import React from 'react'; import { render, cleanup, fireEvent, waitForElement } from '@testing-library/react'; import TestAsync from './TestAsync'afterEach(cleanup);it('increments counter after 0.5s', async () => {const { getByTestId, getByText } = render(<TestAsync />); fireEvent.click(getByTestId('button-up'))const counter = await waitForElement(() => getByText('1')) expect(counter).toHaveTextContent('1')});

To test the incrementing event, we first have to use async/await to handle the action because, as I said earlier, it takes time to complete.

為了測試遞增事件,我們首先必須使用async / await來處理該動作,因為正如我之前所說的,它需要時間才能完成。

Next, we use a new helper method getByText(). This is similar to getByTestId(), except that getByText() selects the text content instead of id or data-testid.

接下來,我們使用新的輔助方法getByText() 。 這類似于getByTestId() ,除了getByText()選擇文本內(nèi)容而不是id或data-testid。

Now, after clicking to the button, we wait for the counter to be incremented with waitForElement(() => getByText('1')). And once the counter incremented to 1, we can now move to the condition and check if the counter is effectively equal to 1.

現(xiàn)在,單擊按鈕后,我們等待使用waitForElement(() => getByText('1'))來增加計數(shù)器。 一旦計數(shù)器增加到1,我們現(xiàn)在可以移至條件并檢查計數(shù)器是否有效等于1。

That being said, let's now move to more complex test cases.

話雖如此,讓我們現(xiàn)在轉(zhuǎn)到更復(fù)雜的測試用例。

Are you ready?

你準(zhǔn)備好了嗎?

5.測試React Redux (5. Testing React Redux)

If you're new to React Redux, this article might help you. Otherwise, let's check what the TestRedux.js looks like.

如果您不熟悉React Redux, 本文可能會為您提供幫助。 否則,讓我們檢查一下TestRedux.js外觀。

  • TestRedux.js

    TestRedux.js

import React from 'react' import { connect } from 'react-redux'const TestRedux = ({counter, dispatch}) => {const increment = () => dispatch({ type: 'INCREMENT' })const decrement = () => dispatch({ type: 'DECREMENT' })return (<><h1 data-testid="counter">{ counter }</h1><button data-testid="button-up" onClick={increment}>Up</button><button data-testid="button-down" onClick={decrement}>Down</button></>)}export default connect(state => ({ counter: state.count }))(TestRedux)

And for the reducer:

對于減速器:

  • store/reducer.js

    store/reducer.js

export const initialState = {count: 0,}export function reducer(state = initialState, action) {switch (action.type) {case 'INCREMENT':return {count: state.count + 1,}case 'DECREMENT':return {count: state.count - 1,}default:return state}}

As you can see, there is nothing fancy – it's just a basic Counter Component handled by React Redux.

如您所見,沒有什么花哨的-它只是由React Redux處理的基本計數(shù)器組件。

Now, let's write the unit tests.

現(xiàn)在,讓我們編寫單元測試。

Test if the initial state is equal to 0:

測試初始狀態(tài)是否等于0:

TestRedux.test.js

TestRedux.test.js

import React from 'react' import { createStore } from 'redux' import { Provider } from 'react-redux' import { render, cleanup, fireEvent } from '@testing-library/react'; import { initialState, reducer } from '../store/reducer' import TestRedux from './TestRedux'const renderWithRedux = (component,{ initialState, store = createStore(reducer, initialState) } = {} ) => {return {...render(<Provider store={store}>{component}</Provider>),store,} }afterEach(cleanup);it('checks initial state is equal to 0', () => {const { getByTestId } = renderWithRedux(<TestRedux />)expect(getByTestId('counter')).toHaveTextContent('0')})

There are a couple of things we need to import to test React Redux. And here, we create our own helper function renderWithRedux() to render the component since it will be used several times.

我們需要導(dǎo)入一些內(nèi)容來測試React Redux。 在這里,我們將創(chuàng)建自己的幫助器函數(shù)renderWithRedux()來呈現(xiàn)組件,因為它將多次使用。

renderWithRedux() receives as parameters the component to render, the initial state, and the store. If there is no store, it will create a new one, and if it doesn't receive an initial state or a store, it returns an empty object.

renderWithRedux()接收要渲染的組件,初始狀態(tài)和存儲作為參數(shù)。 如果沒有存儲,它將創(chuàng)建一個新存儲,如果沒有收到初始狀態(tài)或存儲,則將返回一個空對象。

Next, we use render() to render the component and pass the store to the Provider.

接下來,我們使用render()渲染組件并將商店傳遞給Provider。

That being said, we can now pass the component TestRedux to renderWithRedux() to test if the counter is equal to 0.

話雖如此,我們現(xiàn)在可以將組件TestRedux傳遞給renderWithRedux()以測試計數(shù)器是否等于0 。

Test if the counter increments and decrements correctly:

測試計數(shù)器是否正確遞增和遞減:

TestRedux.test.js (add the following code block to the file)

TestRedux.test.js (將以下代碼塊添加到文件中)

it('increments the counter through redux', () => {const { getByTestId } = renderWithRedux(<TestRedux />, {initialState: {count: 5} })fireEvent.click(getByTestId('button-up'))expect(getByTestId('counter')).toHaveTextContent('6') })it('decrements the counter through redux', () => {const { getByTestId} = renderWithRedux(<TestRedux />, {initialState: { count: 100 },})fireEvent.click(getByTestId('button-down'))expect(getByTestId('counter')).toHaveTextContent('99') })

To test the incrementing and decrementing events, we pass an initial state as a second argument to renderWithRedux(). Now, we can click on the buttons and test if the expected result matches the condition or not.

為了測試遞增和遞減事件,我們將初始狀態(tài)作為第二個參數(shù)傳遞給renderWithRedux() 。 現(xiàn)在,我們可以單擊按鈕并測試預(yù)期結(jié)果是否符合條件。

Now, let's move to the next section and introduce React Context.

現(xiàn)在,讓我們進(jìn)入下一部分并介紹React Context。

React Router and Axios will come next – are you still with me?

接下來是React Router和Axios –您還和我在一起嗎?

6.測試React上下文 (6. Testing React Context)

If you're new to React Context, check out this article first. Otherwise, let's check the TextContext.js file.

如果您不熟悉React Context,請先閱讀本文 。 否則,讓我們檢查TextContext.js文件。

  • TextContext.js

    TextContext.js

import React from "react"export const CounterContext = React.createContext()const CounterProvider = () => {const [counter, setCounter] = React.useState(0)const increment = () => setCounter(counter + 1)const decrement = () => setCounter(counter - 1)return (<CounterContext.Provider value={{ counter, increment, decrement }}><Counter /></CounterContext.Provider>) }export const Counter = () => { const { counter, increment, decrement } = React.useContext(CounterContext) return (<><h1 data-testid="counter">{ counter }</h1><button data-testid="button-up" onClick={increment}> Up</button><button data-testid="button-down" onClick={decrement}>Down</button></>) }export default CounterProvider

Now, the counter state is managed through React Context. Let's write the unit test to check if it behaves as expected.

現(xiàn)在,計數(shù)器狀態(tài)通過React Context進(jìn)行管理。 讓我們編寫單元測試以檢查其行為是否符合預(yù)期。

Test if the initial state is equal to 0:

測試初始狀態(tài)是否等于0:

TextContext.test.js

TextContext.test.js

import React from 'react' import { render, cleanup, fireEvent } from '@testing-library/react' import CounterProvider, { CounterContext, Counter } from './TestContext'const renderWithContext = (component) => {return {...render(<CounterProvider value={CounterContext}>{component}</CounterProvider>)} }afterEach(cleanup);it('checks if initial state is equal to 0', () => {const { getByTestId } = renderWithContext(<Counter />)expect(getByTestId('counter')).toHaveTextContent('0') })

As in the previous section with React Redux, here we use the same approach, by creating a helper function renderWithContext() to render the component. But this time, it receives only the component as a parameter. And to create a new context, we pass CounterContext to the Provider.

與上一節(jié)關(guān)于React Redux的部分一樣,這里我們通過創(chuàng)建一個輔助函數(shù)renderWithContext()來渲染組件,使用相同的方法。 但是這一次,它僅接收組件作為參數(shù)。 為了創(chuàng)建新的上下文,我們將CounterContext傳遞給Provider。

Now, we can test if the counter is initially equal to 0 or not.

現(xiàn)在,我們可以測試計數(shù)器最初是否等于0。

Test if the counter increments and decrements correctly:

測試計數(shù)器是否正確遞增和遞減:

TextContext.test.js (add the following code block to the file)

TextContext.test.js (將以下代碼塊添加到文件中)

it('increments the counter', () => {const { getByTestId } = renderWithContext(<Counter />)fireEvent.click(getByTestId('button-up'))expect(getByTestId('counter')).toHaveTextContent('1')})it('decrements the counter', () => {const { getByTestId} = renderWithContext(<Counter />)fireEvent.click(getByTestId('button-down'))expect(getByTestId('counter')).toHaveTextContent('-1')})

As you can see, here we fire a click event to test if the counter increments correctly to 1 and decrements to -1.

如您所見,這里我們觸發(fā)一個click事件,以測試計數(shù)器是否正確地增加到1并減少到-1。

That being said, we can now move to the next section and introduce React Router.

話雖如此,我們現(xiàn)在可以進(jìn)入下一部分并介紹React Router。

7.測試React Router (7. Testing React Router)

If you want to dive into React Router, this article might help you. Otherwise, let's check the TestRouter.js file.

如果您想深入研究React Router, 這篇文章可能會對您有所幫助。 否則,讓我們檢查TestRouter.js文件。

  • TestRouter.js

    TestRouter.js

import React from 'react' import { Link, Route, Switch, useParams } from 'react-router-dom'const About = () => <h1>About page</h1>const Home = () => <h1>Home page</h1>const Contact = () => {const { name } = useParams()return <h1 data-testid="contact-name">{name}</h1> }const TestRouter = () => {const name = 'John Doe'return (<><nav data-testid="navbar"><Link data-testid="home-link" to="/">Home</Link><Link data-testid="about-link" to="/about">About</Link><Link data-testid="contact-link" to={`/contact/${name}`}>Contact</Link></nav><Switch><Route exact path="/" component={Home} /><Route path="/about" component={About} /><Route path="/about:name" component={Contact} /></Switch></>) }export default TestRouter

Here, we have some components to render when navigating the Home page.

在這里,我們有一些導(dǎo)航主頁時要呈現(xiàn)的組件。

Now, let's write the tests:

現(xiàn)在,讓我們編寫測試:

  • TestRouter.test.js

    TestRouter.test.js

import React from 'react' import { Router } from 'react-router-dom' import { render, fireEvent } from '@testing-library/react' import { createMemoryHistory } from 'history' import TestRouter from './TestRouter'const renderWithRouter = (component) => {const history = createMemoryHistory()return { ...render (<Router history={history}>{component}</Router>)} }it('should render the home page', () => {const { container, getByTestId } = renderWithRouter(<TestRouter />) const navbar = getByTestId('navbar')const link = getByTestId('home-link')expect(container.innerHTML).toMatch('Home page')expect(navbar).toContainElement(link) })

To test React Router, we have to first have a navigation history to start with. Therefore we use createMemoryHistory() to well as the name guessed to create a navigation history.

要測試React Router,我們首先必須有一個導(dǎo)航歷史記錄。 因此,我們使用createMemoryHistory()以及猜測的名稱來創(chuàng)建導(dǎo)航歷史記錄。

Next, we use our helper function renderWithRouter() to render the component and pass history to the Router component. With that, we can now test if the page loaded at the start is the Home page or not. And if the navigation bar is loaded with the expected links.

接下來,我們使用輔助函數(shù)renderWithRouter()渲染組件并將history傳遞給Router組件。 這樣,我們現(xiàn)在可以測試在開始時加載的頁面是否是主頁。 并在導(dǎo)航欄中加載預(yù)期的鏈接。

Test if it navigates to other pages with the parameters when we click on links:

單擊鏈接時,測試是否使用參數(shù)導(dǎo)航到其他頁面:

TestRouter.test.js (add the following code block to the file)

TestRouter.test.js (將以下代碼塊添加到文件中)

it('should navigate to the about page', ()=> {const { container, getByTestId } = renderWithRouter(<TestRouter />) fireEvent.click(getByTestId('about-link'))expect(container.innerHTML).toMatch('About page') })it('should navigate to the contact page with the params', ()=> {const { container, getByTestId } = renderWithRouter(<TestRouter />) fireEvent.click(getByTestId('contact-link'))expect(container.innerHTML).toMatch('John Doe') })

Now, to check if the navigation works, we have to fire a click event on the navigation links.

現(xiàn)在,要檢查導(dǎo)航是否有效,我們必須在導(dǎo)航鏈接上觸發(fā)click事件。

For the first test, we check if the content is equal to the text in the About Page, and for the second, we test the routing params and check if it passed correctly.

對于第一個測試,我們檢查內(nèi)容是否與“關(guān)于頁面”中的文本相等,對于第二個測試,我們測試路由參數(shù)并檢查其是否正確傳遞。

We can now move to the final section and learn how to test an Axios request.

現(xiàn)在,我們可以轉(zhuǎn)到最后一節(jié),學(xué)習(xí)如何測試Axios請求。

We're almost done!

我們快完成了!

8.測試HTTP請求 (8. Testing HTTP Request)

As usual, let's first see what the TextAxios.js file looks like.

與往常一樣,讓我們??首先看一下TextAxios.js文件的外觀。

  • TextAxios.js

    TextAxios.js

import React from 'react' import axios from 'axios'const TestAxios = ({ url }) => {const [data, setData] = React.useState()const fetchData = async () => {const response = await axios.get(url)setData(response.data.greeting) } return (<><button onClick={fetchData} data-testid="fetch-data">Load Data</button>{ data ?<div data-testid="show-data">{data}</div>:<h1 data-testid="loading">Loading...</h1>}</>) }export default TestAxios

As you can see here, we have a simple component that has a button to make a request. And if the data is not available, it will display a loading message.

如您在這里看到的,我們有一個簡單的組件,該組件帶有一個用于發(fā)出請求的按鈕。 并且如果數(shù)據(jù)不可用,它將顯示一條加載消息。

Now, let's write the tests.

現(xiàn)在,讓我們編寫測試。

Test if the data are fetched and displayed correctly:

測試是否已正確提取和顯示數(shù)據(jù):

TextAxios.test.js

TextAxios.test.js

import React from 'react' import { render, waitForElement, fireEvent } from '@testing-library/react' import axiosMock from 'axios' import TestAxios from './TestAxios'jest.mock('axios')it('should display a loading text', () => {const { getByTestId } = render(<TestAxios />)expect(getByTestId('loading')).toHaveTextContent('Loading...') })it('should load and display the data', async () => {const url = '/greeting'const { getByTestId } = render(<TestAxios url={url} />)axiosMock.get.mockResolvedValueOnce({data: { greeting: 'hello there' },})fireEvent.click(getByTestId('fetch-data'))const greetingData = await waitForElement(() => getByTestId('show-data'))expect(axiosMock.get).toHaveBeenCalledTimes(1)expect(axiosMock.get).toHaveBeenCalledWith(url)expect(greetingData).toHaveTextContent('hello there') })

This test case is a bit different because we have to deal with an HTTP request. And to do that, we have to mock an axios request with the help of jest.mock('axios').

這個測試用例有些不同,因為我們必須處理一個HTTP請求。 為此,我們必須借助jest.mock('axios')模擬axios請求。

Now, we can use axiosMock and apply a get() method to it. Finally we will use the Jest function mockResolvedValueOnce() to pass the mocked data as a parameter.

現(xiàn)在,我們可以使用axiosMock并對其應(yīng)用一個get()方法。 最后,我們將使用Jest函數(shù)mockResolvedValueOnce()來傳遞mockResolvedValueOnce()數(shù)據(jù)作為參數(shù)。

With that, now for the second test we can click to the button to fetch the data and use async/await to resolve it. And now we have to test 3 things:

這樣,現(xiàn)在對于第二個測試,我們可以單擊按鈕來獲取數(shù)據(jù)并使用async / await來解決它。 現(xiàn)在我們必須測試3件事:

  • If the HTTP request has been done correctly

    如果HTTP請求已正確完成
  • If the HTTP request has been done with the url

    如果HTTP請求已通過url完成

  • If the data fetched matches the expectation.

    如果獲取的數(shù)據(jù)符合期望。
  • And for the first test, we just check if the loading message is displayed when we have no data to show.

    對于第一個測試,我們只檢查沒有數(shù)據(jù)要顯示時是否顯示加載消息。

    That being said, we're now done with the 8 simple steps to start testing your React Apps.

    話雖如此,我們現(xiàn)在已經(jīng)完成了8個簡單步驟來開始測試React Apps。

    Don't be scared to test anymore.

    不要害怕測試了。

    最后的想法 (Final Thoughts)

    The React Testing Library is a great package for testing React Apps. It gives us access to jest-dom matchers we can use to test our components more efficiently and with good practices. Hopefully this article was useful, and it will help you build robust React apps in the future.

    React Testing庫是用于測試React Apps的出色軟件包。 它使我們能夠訪問jest-dom匹配器,我們可以使用它們來更有效地并通過良好實踐來測試我們的組件。 希望本文對您有所幫助,并在將來幫助您構(gòu)建功能強大的React應(yīng)用。

    You can find the finished project here

    您可以在這里找到完成的項目

    Thanks for reading it!

    感謝您閱讀!

    Read more articles ?- ?Subscribe to my newsletter ? - ? Follow me on twitter

    文章 - 訂閱我的新聞通訊 - 在Twitter上關(guān)注我

    You can read other articles like this on my blog.

    您可以在我的博客上閱讀其他類似的文章 。

    下一步 (Next Steps)

    React Testing Library docs

    React Testing庫文檔

    React Testing Library Cheatsheet

    React測試庫備忘單

    Jest DOM matchers cheatsheet

    笑話DOM匹配器備忘單

    Jest Docs

    笑話文檔

    翻譯自: https://www.freecodecamp.org/news/8-simple-steps-to-start-testing-react-apps-using-react-testing-library-and-jest/

    react jest測試

    總結(jié)

    以上是生活随笔為你收集整理的react jest测试_如何使用React测试库和Jest开始测试React应用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

    久久网站最新地址 | 久久精品九色 | 久久精品美女视频网站 | 日韩高清无线码2023 | 一级理论片在线观看 | 日日夜夜操操操操 | 91网免费观看 | 午夜丁香网 | 久久高清免费 | 一本色道久久精品 | 一区二区三区在线免费观看视频 | 国产精品mv在线观看 | 中文字幕一区二区三区在线播放 | 91黄色在线观看 | 国产区在线| av电影免费 | 美女国内精品自产拍在线播放 | 亚洲国产成人久久综合 | 午夜视频在线观看一区二区 | 日韩大陆欧美高清视频区 | av在线免费观看网站 | 天干啦夜天干天干在线线 | www久久久久 | 亚洲成人二区 | 亚洲午夜久久久久久久久久久 | 又黄又爽免费视频 | 亚洲狠狠婷婷 | 欧洲成人av | av黄色亚洲 | 综合网色| 欧美一区二区三区在线观看 | 99在线精品观看 | 亚洲视频 一区 | 黄色在线免费观看网址 | 999超碰| 网站在线观看日韩 | 久草在线视频网 | 黄色www在线观看 | 国产不卡av在线播放 | 国产美女永久免费 | 日韩综合一区二区三区 | 主播av在线 | 精品嫩模福利一区二区蜜臀 | 91麻豆精品国产91久久久久久久久 | 欧美a√大片 | 久久久电影 | 国产啊v在线观看 | 天天插天天干天天操 | 欧美激情精品久久久 | 麻豆免费在线视频 | 久久免费视频这里只有精品 | 欧美成人亚洲成人 | 日韩欧美一区二区三区在线观看 | 久久免费精彩视频 | 免费在线观看一级片 | 三级在线视频观看 | 久久人人爽人人爽人人片av免费 | 91免费在线视频 | 国产日韩欧美在线看 | 久久不卡电影 | 开心丁香婷婷深爱五月 | 国产视频黄 | 玖玖爱国产在线 | 国产在线播放一区二区三区 | 欧美巨乳网 | 国产又粗又猛又色又黄网站 | 日韩三区在线 | av手机在线播放 | 国产日产欧美在线观看 | 久久首页 | 深夜福利视频在线观看 | 欧美日韩一级视频 | 日本中文字幕一二区观 | 国产精品高清免费在线观看 | 中文字幕高清在线播放 | 欧美亚洲精品一区 | 国产一区免费在线观看 | 黄色91在线 | 日韩美视频 | 久久免费大片 | 亚洲激情网站免费观看 | 91精品国自产在线偷拍蜜桃 | 国产99久久精品一区二区永久免费 | 欧美激情精品久久久久久变态 | 国产综合视频在线观看 | 日韩美一区二区三区 | 中文字幕之中文字幕 | 99精品区 | 色网站免费在线看 | 日本三级全黄少妇三2023 | 色综合久久中文字幕综合网 | 国产一区二区在线影院 | 国产黄a三级三级 | 国产福利中文字幕 | 国产精品自产拍在线观看中文 | 久草在线91 | 国产短视频在线播放 | 97综合在线 | 在线视频 影院 | 久久一区二区三区超碰国产精品 | 日韩黄色免费在线观看 | 在线看片一区 | 国产在线精品播放 | 日韩一级电影在线观看 | 一级a毛片高清视频 | 黄色免费大片 | 毛片永久免费 | 国产一区二区三区午夜 | 国产原厂视频在线观看 | 国产精品完整版 | 色婷婷色| 中文字幕有码在线 | 久久国产免费看 | 久久久麻豆视频 | 在线精品视频在线观看高清 | 国产美女视频黄a视频免费 久久综合九色欧美综合狠狠 | 美女网站久久 | 日本久久久久久科技有限公司 | 天堂在线一区 | 日本精品久久久久中文字幕5 | 精品欧美一区二区三区久久久 | 一区在线免费观看 | 国产日韩欧美在线看 | 国产高清综合 | 国产专区免费 | 国产精品一区二区三区久久 | 一本一道久久a久久精品蜜桃 | 天天操天天怕 | 国产精品一区二区免费视频 | 91成人精品国产刺激国语对白 | 日韩网站在线免费观看 | 亚洲综合情 | 蜜臀av.com| 日韩艹| 国产一区二区三区四区在线 | 国产小视频免费在线网址 | 国产高清在线永久 | 国产一区视频在线观看免费 | 日韩在线网 | 国产999精品视频 | 久久久久欧美精品999 | 五月天亚洲综合小说网 | 丁香婷婷社区 | 欧美做受高潮 | 亚洲日本在线一区 | 国产五月色婷婷六月丁香视频 | 亚洲综合在线一区二区三区 | 国产1区2区3区在线 亚洲自拍偷拍色图 | 亚洲一区精品人人爽人人躁 | 久久久久日本精品一区二区三区 | 色天天中文 | 国产真实精品久久二三区 | 在线超碰av| 免费国产在线精品 | 免费观看性生活大片3 | 最新真实国产在线视频 | 国产视频亚洲精品 | 色在线最新 | av电影免费在线看 | 中文字幕123区| 亚洲国产日韩欧美在线 | 天天做天天爱天天爽综合网 | 免费av免费观看 | 香蕉日日 | 久久久国产精品久久久 | 亚洲国产日韩精品 | 精品国产1区 | 在线一区二区三区 | 日韩视频精品在线 | 97超级碰碰 | 97热在线观看 | 精品国偷自产国产一区 | 久久精品精品电影网 | 伊人黄 | 日韩欧美xxxx | 激情综合电影网 | 在线观看日韩中文字幕 | 狠狠色狠狠色综合系列 | 久艹视频免费观看 | 国产精品夜夜夜一区二区三区尤 | 日本中文字幕视频 | 97超碰资源站 | 免费的黄色的网站 | 国产中文字幕一区 | 五月婷婷在线综合 | 福利区在线观看 | 黄色软件在线观看视频 | 超碰在线公开 | 99精品国产99久久久久久97 | 三级黄色在线 | 热久久最新地址 | 久久伊99综合婷婷久久伊 | 日韩天天操 | 最近中文字幕完整高清 | 天天干天天干天天 | 色综合久久综合网 | 91麻豆精品国产91久久久久久久久 | 精品国产亚洲在线 | 韩国三级一区 | 亚洲不卡av一区二区三区 | 91精品视频免费观看 | 欧美日韩高清在线 | 99激情网| 最近中文字幕免费 | 婷婷丁香七月 | 午夜精品久久久 | 日日噜噜噜噜夜夜爽亚洲精品 | 深夜激情影院 | 黄色视屏免费在线观看 | av在线免费播放 | 国产1区2区3区精品美女 | 国产精品日韩高清 | 日韩av资源在线观看 | 久久精品国产一区 | 在线观看免费黄色 | 不卡电影一区二区三区 | 激情av一区二区 | 亚洲黄色小说网址 | 国产亚洲在线视频 | 黄色网大全 | 欧美成人黄色片 | 国产v在线播放 | 又污又黄网站 | 成年人视频在线免费 | 国产精品18久久久久久vr | 在线免费日韩 | 在线韩国电影免费观影完整版 | 国产99久久久国产精品免费二区 | 毛片一级免费一级 | 婷婷丁香激情 | 久久字幕精品一区 | 亚洲激情网站免费观看 | 911国产| 免费视频久久久 | 国产高清av免费在线观看 | 久久久久久久久久亚洲精品 | 午夜18视频在线观看 | 婷婷色 亚洲 | 在线中文字幕av观看 | 日韩精品专区在线影院重磅 | 亚洲少妇激情 | 中文字幕高清 | 97影视| 人人揉人人揉人人揉人人揉97 | 成年人黄色大全 | 亚洲五月六月 | 最近免费观看的电影完整版 | 国产大尺度视频 | 免费久久网| 日韩黄色在线 | www.色五月.com | 一级黄色a视频 | 婷婷九月丁香 | 中文字幕在线观 | 久久久久免费精品国产小说色大师 | 在线观影网站 | 日韩在线视频免费播放 | 免费观看www7722午夜电影 | 丝袜一区在线 | japanesexxx乱女另类 | 中文字幕日本特黄aa毛片 | 四虎小视频 | 国产精品成人免费一区久久羞羞 | a黄在线观看 | 亚洲在线黄色 | 国产一线二线三线在线观看 | 亚洲无吗视频在线 | 日韩欧美第二页 | 97免费视频在线 | 国产a精品 | 亚洲精品久久久久中文字幕二区 | 免费看黄色小说的网站 | 最新免费中文字幕 | 久草久视频 | 激情欧美国产 | 在线看黄色av | 国产黄色精品在线观看 | 在线观看视频亚洲 | 在线观看免费一区 | 久久视频一区 | 人人爽网站| 超碰av在线免费观看 | 蜜臀av性久久久久av蜜臀三区 | 日韩激情小视频 | 午夜体验区 | av一级在线 | 中文字幕av全部资源www中文字幕在线观看 | 美女视频是黄的免费观看 | 亚洲专区欧美专区 | 欧美日韩视频在线播放 | 国产一区视频在线观看免费 | 久久激情久久 | 国产视频九色蝌蚪 | 国产精品久久久久久久久久免费看 | 777奇米四色 | 亚洲精品在线国产 | 亚洲精品免费在线 | 日韩三级视频 | 黄色视屏av | 99视频免费在线观看 | adn—256中文在线观看 | 国产一区成人在线 | 日韩欧美视频 | 国产亚洲人成网站在线观看 | 97在线免费视频 | 亚洲久草网 | 国产精品1区2区在线观看 | 久久综合给合久久狠狠色 | 国产精品色 | 国产一区二区在线视频观看 | 国产一级h | 国产精品6| 992tv在线 | 九九爱免费视频在线观看 | 在线免费av观看 | 97香蕉超级碰碰久久免费软件 | 日韩午夜精品 | 久久a v电影| 国产午夜影院 | 99精品国产在热久久下载 | 国产精品综合久久久久久 | 特黄特色特刺激视频免费播放 | 91精品国产自产在线观看永久 | 国产精品一区二区在线观看免费 | 午夜av电影| www.久久婷婷 | 日韩欧美在线视频一区二区 | 国产一级黄 | 69av视频在线观看 | 午夜av免费看 | 日韩91精品 | 国产成人精品电影久久久 | 久久99精品国产麻豆宅宅 | 丁香花五月 | 天天操天天色天天 | 亚洲人成免费网站 | 久久久精品在线观看 | 欧美a级在线 | 中文字幕第一页在线视频 | 中文字幕精品www乱入免费视频 | 亚洲视频2 | 九月婷婷人人澡人人添人人爽 | 99综合电影在线视频 | 色吊丝在线永久观看最新版本 | www.五月婷婷.com | 国产精品亚洲片夜色在线 | 欧美性色xo影院 | 国产一级黄色片免费看 | 中文字幕免费观看 | 国产一区二区久久久久 | 久久久久久国产精品久久 | 国产精品18p| 亚洲成av人片一区二区梦乃 | 久久99久久99精品免视看婷婷 | 午夜视频播放 | 亚洲精品国内 | 亚洲 欧美变态 另类 综合 | 色av男人的天堂免费在线 | 在线精品观看国产 | 国产精品一区在线播放 | japanesexxxhd奶水| 亚洲国产精品成人综合 | 国产福利一区二区三区在线观看 | 久久久久麻豆v国产 | 精品一区二区6 | 人人玩人人添人人 | 韩国av电影网| 黄色亚洲免费 | 色综合天 | av高清影院 | 黄色软件在线观看免费 | 黄污污网站 | 在线观看中文字幕2021 | 日韩免费观看视频 | 精品福利网| 久久免费视频观看 | 日韩色视频在线观看 | 99re8这里有精品热视频免费 | 一个色综合网站 | 天天干夜夜擦 | 日韩在线视频免费播放 | 久久国产精品系列 | 久久久午夜剧场 | 色亚洲激情 | 91精品久久久久久 | 久久久国产一区 | 黄免费在线观看 | 精品国产片 | 国产精品精品视频 | 中文字幕2021 | 国产高清视频在线 | 久久视频 | 久综合网 | 国产福利专区 | 欧美资源| 精品久久久久一区二区国产 | 亚洲黄色免费电影 | 色婷av| 麻豆视频免费在线观看 | 国产福利小视频在线 | 网站免费黄 | 探花视频在线观看免费 | 精品在线99| 精品视频区 | 在线免费黄色av | 久久免费观看视频 | 亚洲极色 | 91色视频| 国产视频一区二区在线 | 久久久国产精品网站 | 日本一区二区三区视频在线播放 | 欧美视频一区二 | 亚洲一区动漫 | 不卡中文字幕在线 | 日本精品一区二区三区在线观看 | 免费在线观看午夜视频 | www·22com天天操| 蜜臀av性久久久久av蜜臀三区 | 激情五月婷婷综合 | 美女黄网站视频免费 | 精品一区免费 | 亚洲激情精品 | 97超碰人人看 | 亚洲天堂网站 | 国产视频观看 | 亚洲一区二区高潮无套美女 | 中文字幕在线视频国产 | 精品日韩中文字幕 | 97色噜噜| 欧美老女人xx | 精品日韩中文字幕 | 美女视频国产 | 91桃色视频 | 日韩高清精品一区二区 | 国内99视频 | 激情开心色| 丝袜美女视频网站 | 久久精选视频 | 性色av一区二区三区在线观看 | 国产精品网址在线观看 | 在线观看成人av | 欧美成人影音 | www.成人久久| 免费日韩一区二区 | 狠狠网站 | 亚洲成av人片在线观看香蕉 | 久久精品综合 | 美女亚洲精品 | 国产成人精品在线 | 欧美激情视频一区二区三区免费 | 亚洲精品乱码久久久一二三 | 久久精品影片 | 天天插狠狠插 | 嫩草伊人久久精品少妇av | 99精品99| 国产韩国日本高清视频 | 四虎在线观看网址 | 欧美日韩精品在线观看 | a在线免费观看视频 | 免费在线观看av片 | 国产精品淫 | 亚洲综合视频网 | 欧美激情一区不卡 | 欧洲精品码一区二区三区免费看 | 福利视频区| 亚洲黄色av | 中文字幕亚洲在线观看 | 成年人看片网站 | 免费黄色网止 | 久久精品免费播放 | 国产精品露脸在线 | 久久91久久久久麻豆精品 | 中文字幕在线色 | 69视频永久免费观看 | 国产美女视频黄a视频免费 久久综合九色欧美综合狠狠 | 青春草免费视频 | 日韩特黄av| 免费日韩三级 | 亚洲成人精品久久久 | 久久一区二区三区四区 | 久草在线视频看看 | 欧美高清成人 | 日韩免费在线观看视频 | 国产麻豆电影在线观看 | 国产精品不卡在线观看 | 天天夜操 | 麻豆 videos| 国产精品人成电影在线观看 | 国内揄拍国产精品 | 色www免费视频 | 欧美不卡视频在线 | 天天干夜夜擦 | 操操操干干干 | 成人av中文字幕在线观看 | 久久久国产精品免费 | 中文字幕二区三区 | 国产二区视频在线 | 精品一二三区 | 国产剧情一区二区在线观看 | 亚洲三级网 | 三级黄色网络 | 伊人六月 | 欧美久久久影院 | 国产精品久久久久久久久久妇女 | 免费a网站 | 人人干人人模 | 国产精品婷婷午夜在线观看 | 最新高清无码专区 | 亚洲精品短视频 | 7777精品伊人久久久大香线蕉 | 97在线精品 | 人人dvd | 精品一区二区av | 肉色欧美久久久久久久免费看 | 在线视频你懂得 | 欧美精品在线视频观看 | 粉嫩av一区二区三区免费 | 久久中文精品视频 | 国产精品去看片 | 免费黄色看片 | 97视频在线观看播放 | 九七视频在线观看 | 国产黄网站在线观看 | 国产精品美女久久久免费 | 99综合电影在线视频 | 亚洲天堂网站视频 | 精品成人国产 | 在线亚洲高清视频 | 日韩欧美综合 | 婷婷在线免费 | 在线观看 国产 | 中文在线中文资源 | 中文字幕黄色 | 国产一区网 | 欧美日韩亚洲国产一区 | 欧美视频在线观看免费网址 | 日韩三区在线 | 激情电影在线观看 | 亚洲精品国产精品99久久 | 日韩在线电影 | 日韩在线不卡视频 | av导航福利 | www夜夜操com | 色www精品视频在线观看 | 丁香六月伊人 | 日韩三级免费 | 91污视频在线观看 | 成人久久毛片 | 在线免费观看麻豆 | 91高清视频 | 成人av免费在线 | 色夜影院 | 99精品国产高清在线观看 | 91激情在线视频 | 欧美地下肉体性派对 | 日韩激情久久 | 久久久国产影视 | 国产小视频免费在线网址 | 亚洲精品视频在线观看免费视频 | 国产精品久久精品 | 亚洲综合小说 | 国产丝袜在线 | 免费一级片在线观看 | 午夜精品久久久久久久99无限制 | 久久久99精品免费观看乱色 | 天天射天天干天天操 | 狠狠色丁香婷婷综合久小说久 | av色一区 | 日本精品视频在线观看 | 黄色视屏免费在线观看 | 一级免费av | 有码中文字幕 | 国产丝袜制服在线 | 美女视频黄是免费的 | 中文字幕 在线 一 二 | 成人中心免费视频 | 色av男人的天堂免费在线 | 婷婷六月天天 | 久久久精品电影 | 精品国产资源 | 激情视频在线观看网址 | 日日爽天天| 成人影视免费看 | 在线免费亚洲 | 毛片a级片 | 久久观看免费视频 | 日本大片免费观看在线 | 又黄又爽又色无遮挡免费 | 国产一级精品在线观看 | 久热久草| 日韩精品一区二区三区中文字幕 | 六月婷婷色 | 国产黄色片免费看 | 久久久久久免费视频 | 天天拍天天色 | 中文字幕乱视频 | 91视频传媒 | 黄网站a| av在线等| 免费日韩 精品中文字幕视频在线 | 久久精品国产一区二区三 | 日韩午夜精品福利 | 亚洲精品福利在线观看 | 免费日韩 精品中文字幕视频在线 | 免费麻豆视频 | 99视频+国产日韩欧美 | 国产成人免费高清 | 久草综合视频 | 欧美精品乱码久久久久久按摩 | 国产99久久精品一区二区300 | 国产人成在线视频 | 欧美性粗大hdvideo | 亚洲九九精品 | 欧美一区,二区 | 国产精品11 | 射久久 | 国产一区二区精品在线 | 欧美另类xxxx | 人人干狠狠操 | 日韩资源视频 | 亚洲片在线| www.五月激情.com | 久久久国产视频 | 亚洲综合在线观看视频 | 99热最新精品 | 91网页版免费观看 | 成年人三级网站 | 免费看片色 | 精品久久久久国产免费第一页 | 久久久福利 | 久草资源免费 | 不卡的av在线 | 欧美午夜精品久久久久久孕妇 | 成人欧美一区二区三区在线观看 | 欧美va天堂va视频va在线 | 天天综合久久 | 一本色道久久综合亚洲二区三区 | 日韩特级黄色片 | a v在线视频 | 精品国产视频在线 | 日韩在线看片 | 国产黄色片免费 | 欧美一区二视频在线免费观看 | 91成人短视频在线观看 | 久久天天综合网 | 国产成人综 | 日韩网站免费观看 | 500部大龄熟乱视频使用方法 | 国产精品区一区 | 国产在线视频不卡 | 亚洲欧美精品一区二区 | 91cn国产在线 | 日韩中文免费视频 | 在线视频久 | 久久精品国产成人 | 五月色丁香 | 国产成人一区二 | 超碰人人91 | 正在播放日韩 | 国产高清视频在线免费观看 | 国产91对白在线 | 日本黄色免费大片 | 综合黄色网 | 久保带人 | 黄色毛片网站在线观看 | 一区二区三区免费在线观看视频 | 日韩城人在线 | 国产精品99在线观看 | 黄色三级久久 | 国产精品毛片一区二区三区 | 成人资源在线 | 一区二区三区高清在线观看 | 国产二区免费视频 | 久久99亚洲精品久久久久 | 精品久久久久久国产 | 日韩精品久久中文字幕 | 国产成本人视频在线观看 | 国产精品成人一区二区三区 | www.久久成人 | 国内精品久久久久影院一蜜桃 | 国产中年夫妇高潮精品视频 | 久久国产欧美日韩精品 | 天天爱天天射 | 国产+日韩欧美 | a久久免费视频 | 国产精品va最新国产精品视频 | 成人av电影在线播放 | 日日操日日操 | 午夜999 | 毛片精品免费在线观看 | 久久久久久免费毛片精品 | 国产亚洲精品成人av久久ww | 婷婷在线看 | 日韩三级精品 | 黄色成人91 | 亚洲免费观看在线视频 | 精品久久久影院 | 亚洲欧洲精品一区 | 日本久草电影 | 一区二区三区日韩在线观看 | 国产精品婷婷午夜在线观看 | 久草在线最新视频 | 国产v欧美| 欧美一级片免费在线观看 | 97在线视频免费看 | 天天操天天干天天插 | 九九九九精品 | 国产91综合一区在线观看 | 久久国内免费视频 | 日韩在线免费 | 国产精品激情在线观看 | 黄色片亚洲 | 久久精品国产精品 | 99精彩视频在线观看免费 | 黄色在线观看www | 国产精品第二十页 | 亚洲成人免费在线 | 在线视频一二三 | 国产高清在线视频 | 在线视频日韩一区 | 国产四虎在线 | 69绿帽绿奴3pvideos | 免费日韩一区二区三区 | 麻花豆传媒mv在线观看网站 | 日韩在线视频观看 | 亚洲精品国产电影 | 久久婷婷丁香 | 99热最新| 日韩欧美高清在线观看 | 伊人国产女 | 日韩中文字幕视频在线 | 欧美激情综合色 | 免费av大片 | 亚洲欧美日本A∨在线观看 青青河边草观看完整版高清 | 亚洲激情国产精品 | 国产精品乱码久久久久 | 超碰97av在线 | 国产一区二区高清不卡 | 久久久五月天 | 在线观看岛国片 | 波多野结衣精品 | 亚洲视频精选 | 久久艹影院 | 欧洲精品亚洲精品 | 婷婷综合| 国产精品一区二区免费 | 国产原创中文在线 | 正在播放国产91 | 亚洲 精品在线视频 | 久久99精品一区二区三区三区 | 91精品国自产拍天天拍 | 91porny九色91啦中文 | 久久精品91久久久久久再现 | 亚洲1区在线 | 亚洲电影影音先锋 | 久久人人爽av | 91av九色 | 国产 日韩 在线 亚洲 字幕 中文 | 草久视频在线观看 | 日本中文字幕高清 | 久草在线观看视频免费 | 亚洲视频 一区 | 国产一级一级国产 | 奇米影视999 | 超碰免费在线公开 | 国产精彩在线视频 | 久久国产精品99久久久久久丝袜 | 五月婷婷视频 | 久久6精品 | 亚洲精品在线观看中文字幕 | 天天综合亚洲 | 精品一区在线看 | 国产精品国产三级国产不产一地 | 久久综合九色综合97_ 久久久 | 久久精品79国产精品 | 久久免费福利 | 色亚洲激情 | 久久av一区二区三区亚洲 | 在线视频app | 免费在线观看av电影 | 久久精品波多野结衣 | 日韩在线高清视频 | 国内久久精品 | 狠狠88综合久久久久综合网 | 九九视频在线播放 | 国产在线观看污片 | 亚洲成人av片 | 国产91精品看黄网站在线观看动漫 | 精品福利国产 | 毛片二区 | 亚洲精品久久久久久久不卡四虎 | 在线免费国产 | 精品国产成人在线影院 | 色综合久久88色综合天天6 | 狠狠狠干 | 国产成人精品电影久久久 | 日韩字幕 | av大全在线免费观看 | 午夜精品中文字幕 | 欧美视频在线观看免费网址 | 在线免费观看国产黄色 | 91综合在线| 狠狠狠色丁香综合久久天下网 | 一级成人网 | 国产精品久久久久久麻豆一区 | 精品中文字幕在线播放 | 精品一区二区免费在线观看 | 天天操综合网站 | 91久久久久久久一区二区 | 九九亚洲精品 | 国产欧美精品一区二区三区四区 | 91香蕉视频黄 | 国产又粗又硬又爽视频 | 免费中文字幕 | 婷婷色综合色 | 91av免费观看 | 免费av片在线 | 91麻豆精品国产自产 | 九九一级片 | 国产无限资源在线观看 | 最近日本中文字幕a | 在线观看国产高清视频 | 国产专区在线视频 | 欧产日产国产69 | 色先锋av资源中文字幕 | 国产精品99久久久精品免费观看 | 99久久精品国产亚洲 | 日韩理论视频 | 天天拍天天干 | 91在线看网站 | 国产精品原创在线 | 久久99久国产精品黄毛片入口 | 中文字幕在线视频一区二区 | 中文字幕二区三区 | 欧美特一级片 | 精品福利视频在线观看 | www.eeuss影院av撸 | 亚洲精品视频免费在线 | 在线观看免费版高清版 | 欧美性色网站 | 国产麻豆精品95视频 | 人人干免费 | 在线99| 国产精品日韩欧美一区二区 | 成人av在线观 | 国产高清黄色 | 免费男女羞羞的视频网站中文字幕 | 91成人午夜| 精品在线一区二区 | 欧美激情第一页xxx 午夜性福利 | 亚洲免费av电影 | 美女视频黄免费网站 | 在线免费观看国产黄色 | 国产一卡二卡在线 | 精品久久美女 | 精品国产欧美一区二区三区不卡 | 日韩免费在线观看 | 天天天色综合 | 色老板在线视频 | 91黄色成人 | 国产一级片一区二区三区 | 亚洲精品国产区 | 免费久久久久久久 | 人人超碰在线 | 欧美日韩p片 | 久久久国产一区二区三区四区小说 | 日本动漫做毛片一区二区 | 国产做a爱一级久久 | 国产精品国产亚洲精品看不卡15 | 国产视频在线一区二区 | 操操综合| 精品久久精品久久 | 久亚洲 | 黄色毛片电影 | 蜜臀久久99精品久久久酒店新书 | 国产亚洲va综合人人澡精品 | 一区二区精品在线 | 人人网人人爽 | 天天干天天干天天干 | a在线观看免费视频 | 人人爱天天操 | 欧美日韩国产精品一区二区三区 | 欧美日韩三级在线观看 | 亚洲精品视频在线观看免费视频 | 福利网址在线观看 | www.国产在线观看 | 韩国av在线播放 | 日韩福利在线观看 | 欧美一区二区三区在线 | 中文国产在线观看 | 国产剧情一区在线 | 91黄站| 五月天免费网站 | 91手机电视 | 麻豆视屏| 欧美日韩在线看 | 五月婷香蕉久色在线看 | 日韩精品一区电影 | 国产一级视频在线观看 | 色悠悠久久综合 | 日日碰狠狠添天天爽超碰97久久 | 91精品视频免费在线观看 | 伊人影院99| 日韩在线一二三区 | zzijzzij日本成熟少妇 | 五月婷av | 丝袜精品视频 | 安徽妇搡bbbb搡bbbb | av免费观看网址 | 一区中文字幕电影 | 欧美国产日韩久久 | av免费在线网 | 亚洲综合成人婷婷小说 | 青青河边草免费 | 成人蜜桃网 | 91色亚洲 | 手机看片国产日韩 | 97夜夜澡人人双人人人喊 | 国产视频久久久 | 久久久国产一区二区三区 | 国产日本高清 | 久久999久久 | 免费在线观看成人 | 免费看精品久久片 | 91视频a| 欧美巨大荫蒂茸毛毛人妖 | 91精品小视频 | 久久黄色精品视频 | 日韩v欧美v日本v亚洲v国产v | 色wwww| 亚洲一区二区观看 | 亚洲特级片 | 国产黄色资源 | 99久久久久国产精品免费 | 日韩久久久久久久 | 久草在线最新 | 在线免费观看欧美日韩 | 偷拍精偷拍精品欧洲亚洲网站 | 久久激情五月激情 | 在线免费观看视频你懂的 | 99热99re6国产在线播放 | 黄色小视频在线观看免费 | 夜夜视频 | 免费看国产一级片 | 狠狠色丁香婷婷综合久久片 | 在线观看的av| 福利一区在线 | 成人毛片一区 | 色婷婷久久久 | 九九热中文字幕 | 久草在线手机视频 | av天天在线观看 | 在线v片 | 成 人 黄 色 视频免费播放 | 中文在线a∨在线 | 探花视频在线观看免费 | 日日草夜夜操 | 在线免费观看的av网站 | 国产高清av免费在线观看 | 女人高潮一级片 | 一区二区三区免费在线 | 婷婷六月天综合 | 最近中文字幕免费大全 | 国产精品6 | 超碰国产在线播放 | 精品日韩中文字幕 | 久久 国产一区 | 成人一区在线观看 | 久久综合亚洲鲁鲁五月久久 | 亚洲最快最全在线视频 | 在线欧美日韩 | 久久av中文字幕片 | 在线不卡中文字幕播放 | 精品国模一区二区 | 涩av在线| 午夜影视av | 国产精品久久久久一区二区三区共 | 国产精品福利无圣光在线一区 | 成人蜜桃网| 天天色天天射综合网 | 欧美一级在线 | av短片在线 | 日韩aⅴ视频 | 2023亚洲精品国偷拍自产在线 | 网站在线观看日韩 | 久久精品99国产精品亚洲最刺激 | 99在线观看免费视频精品观看 | 亚洲精品天天 | 色综合久久综合中文综合网 | 少妇搡bbbb搡bbb搡忠贞 | 色综合天天天天做夜夜夜夜做 | 911久久香蕉国产线看观看 | 黄av免费在线观看 | 能在线观看的日韩av | 永久免费的啪啪网站免费观看浪潮 | 午夜精品av | 51久久夜色精品国产麻豆 | 国产在线v |