{"id":15671474,"url":"https://github.com/egoist/react-jest","last_synced_at":"2025-05-06T20:25:56.815Z","repository":{"id":45275508,"uuid":"89237538","full_name":"egoist/react-jest","owner":"egoist","description":"Run Jest tests for React app.","archived":false,"fork":false,"pushed_at":"2021-12-25T13:53:40.000Z","size":61,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T15:45:37.345Z","etag":null,"topics":["jest","react"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egoist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-24T12:28:01.000Z","updated_at":"2021-01-27T23:24:31.000Z","dependencies_parsed_at":"2022-09-22T19:51:53.167Z","dependency_job_id":null,"html_url":"https://github.com/egoist/react-jest","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Freact-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Freact-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Freact-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Freact-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/react-jest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252763147,"owners_count":21800439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jest","react"],"created_at":"2024-10-03T15:02:36.674Z","updated_at":"2025-05-06T20:25:56.797Z","avatar_url":"https://github.com/egoist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-jest\n\n[![NPM version](https://img.shields.io/npm/v/react-jest.svg?style=flat)](https://npmjs.com/package/react-jest) [![NPM downloads](https://img.shields.io/npm/dm/react-jest.svg?style=flat)](https://npmjs.com/package/react-jest) [![CircleCI](https://circleci.com/gh/egoist/react-jest/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/react-jest/tree/master)  [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026style=flat)](https://github.com/egoist/donate)\n\nInspired by `create-react-app` but `react-jest` comes as a standalone module, basically this would work out of the box for projects created by `create-react-app` and most React projects.\n\n## Install\n\n```bash\n# Recommend\nyarn add react-jest --dev\n# Alternative\n# yarn global add react-jest\n```\n\n## Features\n\n- `.js|jsx` files are transformed with `babel-preset-react-app` which is used by `create-react-app`, you can also use custom `.babelrc`.\n- Run tests in `jsdom` enviroment by default.\n- Importing css files would return an empty object, while importing other kinds of file would return the path to it.\n- Support all Jest cli options.\n- Support API usage.\n\n## Usage\n\nLet's say that you already wrote some jest tests for your React app, for example `src/App.test.js`, then configure npm scripts:\n\n```js\n{\n  \"scripts\": {\n    \"test\": \"react-jest\"\n  }\n}\n```\n\n Then run `npm test`, and it accepts all [jest cli options](https://facebook.github.io/jest/docs/cli.html), for example if you don't need browser environment, use `react-jest --env=node`.\n\n \u003cimg src=\"https://ooo.0o0.ooo/2017/04/24/58fdf89eda405.png\" alt=\"preview\" /\u003e\n\n Which is also worth noting, you can still configure `jest` field in `package.json`, `react-jest` will load it automatically.\n\n## API\n\nBesides using as a CLI utility, you can also use the `react-jest` node.js API.\n\n```js\nconst runJest = require('react-jest')\n\nrunJest(options)\n```\n\n### options\n\n#### jestConfig\n\nType: `object` `function`\n\n*- object:*\n\nUse your [custom jest config](https://facebook.github.io/jest/docs/configuration.html#content) which will be merged (using lodash.merge) with base jest config.\n\n*- function:*\n\nUse a function to mutate base jest config:\n\n```js\nfunction mutateJestConfig(config) {\n  // Use polyfill before each test\n  config.setupFiles = ['./src/polyfills.js']\n  return config\n}\n```\n\n#### argv\n\nType: `Array`\n\nAddtional CLI arguments for jest cli, like `['--env=node']`\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n\n## Author\n\n**react-jest** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.\u003cbr\u003e\nAuthored and maintained by egoist with help from contributors ([list](https://github.com/egoist/react-jest/contributors)).\n\n\u003e [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Freact-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Freact-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Freact-jest/lists"}