<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube" -->

---
title: Using AI to Write Tests for React Components | daily.dev
description: A practical comparison of GitHub Copilot and ChatGPT for generating tests for React Native components, using the open-source Expensify app as a test subject....
canonical: https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using AI to Write Tests for React Components | daily.dev
og:description: A practical comparison of GitHub Copilot and ChatGPT for generating tests for React Native components, using the open-source Expensify app as a test subject....
og:url: https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube
og:image: https://api.daily.dev/og/posts/xgsoy9Ube.png
og:image:alt: Using AI to Write Tests for React Components
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using AI to Write Tests for React Components

**[Callstack Blog](https://daily.dev/sources/callstack-blog)** · 14 min read · 0 upvotes · 0 comments

## Summary

A practical comparison of GitHub Copilot and ChatGPT for generating tests for React Native components, using the open-source Expensify app as a test subject. Both tools produce better results with human guidance and explicit context. Copilot works inline in the IDE but lacks project-wide context, while ChatGPT handles full component code pasted directly and generally produces more accurate initial results. Common pitfalls include hallucinated test IDs, incorrect mock assertions, and missing HOC mocks. The post also covers privacy concerns around sending code to third-party servers, and looks ahead at upcoming tools like GitHub TestPilot, Copilot X, and self-hosted LLMs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.callstack.com/blog/using-ai-to-write-tests-for-react-components>

## Similar posts on daily.dev

- [Practical Use Of AI Coding Tools For The Responsible Developer — Smashing Magazine](https://daily.dev/posts/practical-use-of-ai-coding-tools-for-the-responsible-developer-smashing-magazine-e5s7vecpu) · Smashing Magazine · 6 upvotes · 0 comments
- [GitHub Copilot app for Beginners: Getting started](https://daily.dev/posts/github-copilot-app-for-beginners-getting-started-xmhu8qors) · GitHub Blog · 1 upvotes · 0 comments
- [Quickstart with GitHub Copilot](https://daily.dev/posts/quickstart-with-github-copilot-2dras5fhj) · Serokell · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#github](https://daily.dev/tags/github), [#chatgpt](https://daily.dev/tags/chatgpt), [#react-native](https://daily.dev/tags/react-native)

[View this post on daily.dev](https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using AI to Write Tests for React Components","url":"https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube"},"datePublished":"2026-03-22T11:30:50.575Z","dateModified":"2026-03-22T11:35:47.048Z","description":"A practical comparison of GitHub Copilot and ChatGPT for generating tests for React Native components, using the open-source Expensify app as a test subject....","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8153a6d5536a9010ddb6eb45c6441298?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8153a6d5536a9010ddb6eb45c6441298?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Callstack Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Callstack Blog","logo":"https://media.daily.dev/image/upload/s--3qItoroi--/f_auto,q_auto/v1774179048/logos/callstack-blog?_a=BAMAMiWQ0","url":"https://daily.dev/sources/callstack-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-ai-to-write-tests-for-react-components-xgsoy9ube","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,github,chatgpt,react-native","timeRequired":"PT14M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Callstack Blog","item":"https://daily.dev/sources/callstack-blog"},{"@type":"ListItem","position":3,"name":"Using AI to Write Tests for React Components"}]}
```

