I have done this by using -- to pass custom arguments to the npm script.

Documentation on this option can be found here: https://docs.npmjs.com/cli/run-script

So, to run a single test in a create-react-app application, I run the following:

npm run test -- -t 'test-name'

Where test-name is the value used in the describe function in jest -

describe('test-name', () => {
  it('does something', () => { ... });
});
Answer from user210757 on Stack Overflow
🌐
Create React App
create-react-app.dev › docs › running-tests
Running Tests | Create React App
Add a .travis.yml file to your git repository. language: node_js node_js: - 8 cache: directories: - node_modules script: - npm run build - npm test Copy
🌐
GitHub
github.com › facebook › create-react-app › issues › 11185
Issue with running single test with jest command · Issue #11185 · facebook/create-react-app
After initialize a JS react project with create-react-app, I'm unable to run individual test with jest command. I tried to run test against a single file, I saw · Yep, no luck · npx create-react-app my-app · ./node_modules/.bin/jest src/App.test.js · when run ./node_modules/.bin/jest src/App.test.js, no error emits.
🌐
GitHub
gist.github.com › natterstefan › a20f5fc808a2955fbc208cb144367002
VSCode | Debug tests in Create-React-App (all or single file) · GitHub
Clone this repository at <script src="https://gist.github.com/natterstefan/a20f5fc808a2955fbc208cb144367002.js"></script> Save natterstefan/a20f5fc808a2955fbc208cb144367002 to your computer and use it in GitHub Desktop. Download ZIP · VSCode | Debug tests in Create-React-App (all or single file) Raw ·
🌐
GitHub
github.com › facebook › react › issues › 4529
testing, is there a simple way to run test individually? · Issue #4529 · facebook/react
July 30, 2015 - There was an error while loading. Please reload this page · ➜ react git:(master) ✗ NODE_ENV=test jest
Author   zzz6519003
🌐
YouTube
youtube.com › watch
how to run single unit test file cases | Reactjs unit testing #unittesting - YouTube
In this video I will show you how you can run a single file test cases using a command in React.is you can also use this command with any is framework or lib...
Published   February 20, 2023
🌐
GitHub
github.com › facebook › create-react-app › issues › 7324
react-scripts test --onlyChanged always runs ALL tests instead of only the changed tests, yarn jest --onlyChanged works as expected. · Issue #7324 · facebook/create-react-app
July 5, 2019 - If I edit /node_modules/react-scripts/scripts/test.js so that only the following options are passed to Jest: "argv [ '-o' ]" Jest will still attempt to run all the tests so this doesn't seem like a configuration issue.
Author   LaurensBosscher
🌐
daily.dev
daily.dev › home › blog › get into tech › test cases for react js: a starter guide
Test Cases for React JS: A Starter Guide
December 22, 2025 - npm install --save-dev jest @testing-library/react · Test files end with .test.js or .spec.js.
Find elsewhere
🌐
Marcusoft
marcusoft.net › 2021 › 05 › run-react-script-tests-without-watch.html
Run react-script tests without watch - marcusoft.net
May 31, 2021 - This is done through the react-scripts package. For the react-script test it is internally calling Jest. No tests found related to files changed since the last commit. is the error message that keeps popping up for us. It’s not an error either but just some information.
🌐
O'Reilly
oreilly.com › library › view › react-16-tooling › 9781788835015 › b42d3175-db9f-42d8-af91-1d4a7e450554.xhtml
Running tests using react-scripts - React 16 Tooling [Book]
This test is added so that Jest will find a test that it can run. It doesn't actually test anything meaningful in your application, so you'll probably delete it once more tests are added. Additionally, create-react-app adds the appropriate script to your package.json file to run your tests.
🌐
GitHub
github.com › jpavon › react-scripts-ts
GitHub - jpavon/react-scripts-ts: @jpavon/react-scripts-ts, react-scripts with ts-loader and type checker on a separate process.
Check out the template files for usage examples. npx create-react-app my-app --scripts-version=@jpavon/react-scripts-ts cd my-app/ yarn start ... { "scripts": { "start": "react-scripts-ts start", "build": "react-scripts-ts build", "test": "react-scripts-ts test --env=jsdom", } }
Starred by 84 users
Forked by 17 users
Languages   JavaScript 90.3% | TypeScript 7.1% | HTML 1.4% | CSS 1.2% | JavaScript 90.3% | TypeScript 7.1% | HTML 1.4% | CSS 1.2%
🌐
npm
npmjs.com › package › react-scripts-test
react-scripts-test - npm
September 25, 2016 - This package includes scripts and configuration used by Create React App.
      » npm install react-scripts-test
    
🌐
Inspirnathan
inspirnathan.com › posts › 148-how-to-test-single-file-with-jest
How to Test a Single File with Jest - inspirnathan.com
October 14, 2022 - We can run this script by passing an environment variable to it, so Jest runs only that particular file: ... Pretty cool! In this tutorial, we have learned three different ways of running tests in a single file using Jest. By default, Jest will try to run files that end in .test.js or .spec.js, but we can also pass the name of a file or directory to the Jest CLI to tell it to run only one file instead.
🌐
DEV Community
dev.to › knowicki024 › setting-up-test-files-in-react-with-jest-26la
Setting up test files in React with Jest - DEV Community
February 29, 2024 - "name": "client", "version": "0.1.0", "private": true, "proxy": "http://localhost:3000", "dependencies": { --->"@testing-library/jest-dom": "^5.17.0", --->"@testing-library/react": "^13.4.0", --->"@testing-library/user-event": "^13.5.0", "bootstrap": "^5.3.3", "react": "^18.2.0", "react-bootstrap": "^2.10.1", "react-dom": "^18.2.0", "react-router-dom": "^6.22.1", "react-scripts": "5.0.1", "web-vitals": "^2.1.4" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", --->"test": "react-scripts test", "eject": "react-scripts eject" You can see under our "dependencies" there is the Jest package installed and the "test" line in our "scripts". The best way to set up your test files is to create a folder in your /src folder and name it __tests__.
🌐
Medium
medium.com › @elysiumceleste › how-to-run-tests-for-a-specific-file-in-jest-a85e4ed31c2d
How to Run Tests for a Specific File in Jest | by Elysium Celeste | Medium
November 9, 2023 - To run tests for a specific file in Jest, you can use the --findRelatedTests option followed by the path to the target file.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-test-a-react-app-with-jest-and-react-testing-library
How To Test a React App with Jest and React Testing Library | DigitalOcean
May 9, 2022 - A minimum of one test block is required in each test file. Each test block accepts two required parameters: the first argument is a string representing the name of the test case; the second argument is a function that holds the expectations of the test. Inside the function, there is a render ...
🌐
Jest
jestjs.io › testing react apps
Testing React Apps · Jest
We are using the babel-jest package and the react babel preset to transform our code inside of the test environment. Also see using babel. ... Your package.json should look something like this (where <current-version> is the actual latest version number for the package). Please add the scripts and jest configuration entries: