2022-03-16
3344
#jest#react
Juan Cruz Martinez
34905
Mar 16, 2022 â‹… 11 min read

React app testing: Jest and React Testing Library

Juan Cruz Martinez I'm an entrepreneur, developer, author, speaker, YouTuber, and doer of things.

Recent posts:

Comparing Hattip Vs Express Js For Modern Application Development

Comparing Hattip vs. Express.js for modern app development

Explore what Hattip is, how it works, its benefits and key features, and the differences between Hattip and Express.js.

Antonello Zanini
May 2, 2024 â‹… 8 min read
Using React Shepherd To Build A Site Tour

Using React Shepherd to build a site tour

React Shepherd stands out as a site tour library due to its elegant UI and out-of-the-box, easy-to-use React Context implementation.

Onuorah Bonaventure
May 1, 2024 â‹… 14 min read
A Guide To Cookies In Next Js

A guide to cookies in Next.js

Cookies are crucial to web development. This article will explore how to handle cookies in your Next.js applications.

Georgey V B
Apr 30, 2024 â‹… 10 min read
Handling Dates In JavaScript With Tempo

Handling dates in JavaScript with Tempo

Use the Tempo library to format dates and times in JavaScript while accounting for time zones, daylight saying time, and date internationalization.

Amazing Enyichi Agu
Apr 30, 2024 â‹… 8 min read
View all posts

2 Replies to "React app testing: Jest and React Testing Library"

  1. There is a missing chunk of code on the bottom of the first code block for App.js. The code does not work as it is. If you are stuck there, use the following code.

    “`
    import ‘./App.css’;
    import { useState, useEffect } from ‘react’;
    import { formatUserName } from ‘./utils’;

    function App() {
    const [users, setUsers] = useState([]);
    // load data from server

    useEffect(()=> {
    let mounted = true;
    const getUsers = async () => {
    await fetch(‘https://jsonplaceholder.typicode.com/users’)
    .then(response => response.json())
    .then((data) => {
    if (mounted) {
    setUsers(data);
    }
    })
    }
    getUsers();
    },[]);

    return (

    Users:

    {
    users.map( user => (
    { user.name } { formatUserName(user.username) }
    ))
    }

    );
    }

    export default App;
    “`

Leave a Reply