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:

gemini 3 and antigravity

A developer’s guide to Antigravity and Gemini 3

Check out Google’s latest AI releases, Gemini and the Antigravity AI IDE. Understand what’s new, how they work, and how they can reshape your development workflow.

Elijah Asaolu
Dec 4, 2025 ⋅ 6 min read
bun 1.3 javascript runtime what's new

Bun 1.3: Is it time for devs to rethink the Node stack?

Learn about Bun 1.3, which marks a shift from fast runtime to full JS toolchain—and see the impact of Anthropic’s acquisition of Bun.

Alex Merced
Dec 4, 2025 ⋅ 9 min read

Stop using JavaScript to solve CSS problems

Stop defaulting to JavaScript. Modern CSS handles virtualization, responsive layouts, and scroll animations better than ever – with far less code.

Chizaram Ken
Dec 4, 2025 ⋅ 7 min read
replay december 3

The Replay (12/3/25): React’s next era, AI code review tools, and more

React’s next era, AI code review tools, and more: discover what’s new in The Replay, LogRocket’s newsletter for dev and engineering leaders, in the December 3rd issue.

Matt MacCormack
Dec 3, 2025 ⋅ 30 sec 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

Hey there, want to help make our blog better?

Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.

Sign up now