当前位置:首页 >> 中医保健 >> 如何应用于Cypress测试React原生应用

如何应用于Cypress测试React原生应用

发布时间:2023-02-25

act技术的发展,它有一个API调用。

脱氧核糖核酸

import React, { useEffect, useState } from 'react';

import { ActivityIndicator, FlatList, Text, View } from 'react-native';

export default function App() {

const [isLoading, setLoading] = useState(true);

const [data, setData] = useState([]);

useEffect(() => {

fetch('')

.then((response) => response.json())

.then((json) => setData(json.data))

.catch((error) => console.error(error))

.finally(() => setLoading(false));

}, []);

return (

{isLoading ? : (

accessibilityLabel="users"

data={data}

renderItem={({ item }) => (

{item.id}, {item.first_name}, {item.email}

)}

/>

)}

);

};

上面的编译器调用API 返回四组JSON值。我们必要能够论断body和status等的具体内容。

在React Native技术的发展中会有效性API调用的CypressCGI

脱氧核糖核酸

describe('My First Test', () => {

it('Verify API', () => {

cy.intercept('*/users?*').as('users');

cy.visit('');

cy.wait('@users').then(({response}) => {

expect(response.statusCode).to.eq(200)

expect(response.body.data.length).to.eq(6)

expect(response.body.data[0].email).to.eq('george.bluth@reqres.in')

})

});

})

在上面的编译器中会,我们用作Cypress Intercept特性,等候API载入。然后我们从API中会得到号召,并在飞行测试中会有效性它:

这样我们就可以在Cypress中会飞行测试React原生技术的发展。此外,我们还可以设置Viewport并将其更改为不同的电子元件解像度,以便飞行测试移动Web客户端。

原文标题:Test React Native Apps With Cypress,作者:Ganesh Hegde

济南皮肤病医院地址
江苏男科专科医院有哪些
北京看白癜风哪家最好
江苏妇科医院哪家治疗最好
重庆皮肤病治疗费用是多少
标签:
友情链接: