{"id":13406430,"url":"https://github.com/jestjs/jest","last_synced_at":"2025-09-09T20:35:09.162Z","repository":{"id":12409137,"uuid":"15062869","full_name":"jestjs/jest","owner":"jestjs","description":"Delightful JavaScript Testing.","archived":false,"fork":false,"pushed_at":"2025-05-02T23:33:00.000Z","size":307128,"stargazers_count":44738,"open_issues_count":319,"forks_count":6536,"subscribers_count":560,"default_branch":"main","last_synced_at":"2025-05-05T09:37:39.666Z","etag":null,"topics":["easy","expectation","facebook","immersive","javascript","painless","painless-javascript-testing","snapshot","testing"],"latest_commit_sha":null,"homepage":"https://jestjs.io","language":"TypeScript","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/jestjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":".github/SUPPORT.md","governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"jest"}},"created_at":"2013-12-10T00:18:04.000Z","updated_at":"2025-05-05T06:56:23.000Z","dependencies_parsed_at":"2023-07-27T20:29:32.015Z","dependency_job_id":"2e0b852d-4361-4cf4-83b2-6eba7bdbfc6a","html_url":"https://github.com/jestjs/jest","commit_stats":{"total_commits":7011,"total_committers":1682,"mean_commits":4.168252080856123,"dds":0.7628013122236486,"last_synced_commit":"0a0a9f7375a3b5eb33ea0a7f29afd19b473ec423"},"previous_names":["facebook/jest"],"tags_count":297,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jestjs%2Fjest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jestjs%2Fjest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jestjs%2Fjest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jestjs%2Fjest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jestjs","download_url":"https://codeload.github.com/jestjs/jest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252486140,"owners_count":21755824,"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":["easy","expectation","facebook","immersive","javascript","painless","painless-javascript-testing","snapshot","testing"],"created_at":"2024-07-30T19:02:30.084Z","updated_at":"2025-05-05T10:51:29.175Z","avatar_url":"https://github.com/jestjs.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/jest\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/jest\" alt=\"npm version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/jestjs/jest/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"Jest is released under the MIT license.\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/intent/follow?screen_name=jestjs_\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/jestjs_.svg?style=social\u0026label=Follow%20@jestjs_\" alt=\"Follow on Twitter\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/jestjs/jest/actions/workflows/nodejs.yml\"\u003e\u003cimg alt=\"GitHub CI Status\" src=\"https://img.shields.io/github/actions/workflow/status/jestjs/jest/nodejs.yml?label=CI\u0026logo=GitHub\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/github/jestjs/jest\"\u003e\u003cimg alt=\"Coverage Status\" src=\"https://img.shields.io/codecov/c/github/jestjs/jest/main.svg?maxAge=43200\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://gitpod.io/#https://github.com/jestjs/jest\"\u003e\u003cimg alt=\"Gitpod ready-to-code\" src=\"https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003c!-- A spacer --\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"website/static/img/jest-readme-headline.png\" width=\"80%\"/\u003e\u003c/p\u003e\n\n\u003ch2 align=\"center\"\u003e🃏 Delightful JavaScript Testing\u003c/h2\u003e\n\n**👩🏻‍💻 Developer Ready**: A comprehensive JavaScript testing solution. Works out of the box for most JavaScript projects.\n\n**🏃🏽 Instant Feedback**: Fast, interactive watch mode only runs test files related to changed files.\n\n**📸 Snapshot Testing**: Capture snapshots of large objects to simplify testing and to analyze how they change over time.\n\n\u003cp align=\"right\"\u003e\u003cem\u003eSee more on \u003ca href=\"https://jestjs.io\"\u003ejestjs.io\u003c/a\u003e\u003c/em\u003e\u003c/p\u003e\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n- [Running from command line](#running-from-command-line)\n- [Additional Configuration](#additional-configuration)\n  - [Generate a basic configuration file](#generate-a-basic-configuration-file)\n  - [Using Babel](#using-babel)\n  - [Using webpack](#using-webpack)\n  - [Using Vite](#using-vite)\n  - [Using Parcel](#using-parcel)\n  - [Using Typescript](#using-typescript)\n- [Documentation](#documentation)\n- [Badge](#badge)\n- [Contributing](#contributing)\n  - [Code of Conduct](#code-of-conduct)\n  - [Contributing Guide](#contributing-guide)\n  - [Good First Issues](#good-first-issues)\n- [Credits](#credits)\n  - [Backers](#backers)\n  - [Sponsors](#sponsors)\n- [License](#license)\n- [Copyright](#copyright)\n\n## Getting Started\n\n\u003c!-- copied from Getting Started docs, links updated to point to Jest website --\u003e\n\nInstall Jest using [`yarn`](https://yarnpkg.com/en/package/jest):\n\n```bash\nyarn add --dev jest\n```\n\nOr [`npm`](https://www.npmjs.com/package/jest):\n\n```bash\nnpm install --save-dev jest\n```\n\nNote: Jest documentation uses `yarn` commands, but `npm` will also work. You can compare `yarn` and `npm` commands in the [yarn docs, here](https://yarnpkg.com/en/docs/migrating-from-npm#toc-cli-commands-comparison).\n\nLet's get started by writing a test for a hypothetical function that adds two numbers. First, create a `sum.js` file:\n\n```javascript\nfunction sum(a, b) {\n  return a + b;\n}\nmodule.exports = sum;\n```\n\nThen, create a file named `sum.test.js`. This will contain our actual test:\n\n```javascript\nconst sum = require('./sum');\n\ntest('adds 1 + 2 to equal 3', () =\u003e {\n  expect(sum(1, 2)).toBe(3);\n});\n```\n\nAdd the following section to your `package.json`:\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"jest\"\n  }\n}\n```\n\nFinally, run `yarn test` or `npm test` and Jest will print this message:\n\n```bash\nPASS  ./sum.test.js\n✓ adds 1 + 2 to equal 3 (5ms)\n```\n\n**You just successfully wrote your first test using Jest!**\n\nThis test used `expect` and `toBe` to test that two values were exactly identical. To learn about the other things that Jest can test, see [Using Matchers](https://jestjs.io/docs/using-matchers).\n\n## Running from command line\n\nYou can run Jest directly from the CLI (if it's globally available in your `PATH`, e.g. by `yarn global add jest` or `npm install jest --global`) with a variety of useful options.\n\nHere's how to run Jest on files matching `my-test`, using `config.json` as a configuration file and display a native OS notification after the run:\n\n```bash\njest my-test --notify --config=config.json\n```\n\nIf you'd like to learn more about running `jest` through the command line, take a look at the [Jest CLI Options](https://jestjs.io/docs/cli) page.\n\n## Additional Configuration\n\n### Generate a basic configuration file\n\nBased on your project, Jest will ask you a few questions and will create a basic configuration file with a short description for each option:\n\n```bash\nyarn create jest\n```\n\n### Using Babel\n\nTo use [Babel](https://babeljs.io/), install required dependencies via `yarn`:\n\n```bash\nyarn add --dev babel-jest @babel/core @babel/preset-env\n```\n\nConfigure Babel to target your current version of Node by creating a `babel.config.js` file in the root of your project:\n\n```javascript\n// babel.config.js\nmodule.exports = {\n  presets: [['@babel/preset-env', {targets: {node: 'current'}}]],\n};\n```\n\nThe ideal configuration for Babel will depend on your project. See [Babel's docs](https://babeljs.io/docs/en/) for more details.\n\n\u003cdetails\u003e\n  \u003csummary markdown=\"span\"\u003e\u003cstrong\u003eMaking your Babel config jest-aware\u003c/strong\u003e\u003c/summary\u003e\n\nJest will set `process.env.NODE_ENV` to `'test'` if it's not set to something else. You can use that in your configuration to conditionally setup only the compilation needed for Jest, e.g.\n\n```javascript\n// babel.config.js\nmodule.exports = api =\u003e {\n  const isTest = api.env('test');\n  // You can use isTest to determine what presets and plugins to use.\n\n  return {\n    // ...\n  };\n};\n```\n\n\u003e Note: `babel-jest` is automatically installed when installing Jest and will automatically transform files if a babel configuration exists in your project. To avoid this behavior, you can explicitly reset the `transform` configuration option:\n\n```javascript\n// jest.config.js\nmodule.exports = {\n  transform: {},\n};\n```\n\n\u003c/details\u003e\n\n\u003c!-- Note that the Babel 6 section in the Getting Started was removed --\u003e\n\n### Using webpack\n\nJest can be used in projects that use [webpack](https://webpack.js.org/) to manage assets, styles, and compilation. webpack does offer some unique challenges over other tools. Refer to the [webpack guide](https://jestjs.io/docs/webpack) to get started.\n\n### Using Vite\n\nJest can be used in projects that use [vite](https://vitejs.dev/) to serves source code over native ESM to provide some frontend tooling, vite is an opinionated tool and does offer some out-of-the box workflows. Jest is not fully supported by vite due to how the [plugin system](https://github.com/vitejs/vite/issues/1955#issuecomment-776009094) from vite works, but there is some working examples for first-class jest integration using the `vite-jest`, since this is not fully supported, you might as well read the [limitation of the `vite-jest`](https://github.com/sodatea/vite-jest/tree/main/packages/vite-jest#limitations-and-differences-with-commonjs-tests). Refer to the [vite guide](https://vitejs.dev/guide/) to get started.\n\n### Using Parcel\n\nJest can be used in projects that use [parcel-bundler](https://parceljs.org/) to manage assets, styles, and compilation similar to webpack. Parcel requires zero configuration. Refer to the official [docs](https://parceljs.org/docs/) to get started.\n\n### Using TypeScript\n\nJest supports TypeScript, via Babel. First, make sure you followed the instructions on [using Babel](#using-babel) above. Next, install the `@babel/preset-typescript` via `yarn`:\n\n```bash\nyarn add --dev @babel/preset-typescript\n```\n\nThen add `@babel/preset-typescript` to the list of presets in your `babel.config.js`.\n\n```diff\n// babel.config.js\nmodule.exports = {\n  presets: [\n    ['@babel/preset-env', {targets: {node: 'current'}}],\n+    '@babel/preset-typescript',\n  ],\n};\n```\n\nHowever, there are some [caveats](https://babeljs.io/docs/en/babel-plugin-transform-typescript#caveats) to using TypeScript with Babel. Because TypeScript support in Babel is purely transpilation, Jest will not type-check your tests as they are run. If you want that, you can use [ts-jest](https://github.com/kulshekhar/ts-jest) instead, or just run the TypeScript compiler [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html) separately (or as part of your build process).\n\n\u003c!-- end copied --\u003e\n\n## Documentation\n\nLearn more about using [Jest on the official site!](https://jestjs.io)\n\n- [Getting Started](https://jestjs.io/docs/getting-started)\n- [Guides](https://jestjs.io/docs/snapshot-testing)\n- [API Reference](https://jestjs.io/docs/api)\n- [Configuring Jest](https://jestjs.io/docs/configuration)\n\n## Badge\n\nShow the world you're using _Jest_ `→` [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/jestjs/jest) [![jest tested](https://img.shields.io/badge/Jest-tested-eee.svg?logo=jest\u0026labelColor=99424f)](https://github.com/jestjs/jest) [![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/jestjs/jest)\n\n\u003c!-- prettier-ignore --\u003e\n```md\n[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg?logo=jest)](https://github.com/jestjs/jest)\n[![jest tested](https://img.shields.io/badge/Jest-tested-eee.svg?logo=jest\u0026labelColor=99424f)](https://github.com/jestjs/jest)\n[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/jestjs/jest)\n```\n\n## Contributing\n\nDevelopment of Jest happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Jest.\n\n### [Code of Conduct](https://code.facebook.com/codeofconduct)\n\nFacebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.\n\n### [Contributing Guide](CONTRIBUTING.md)\n\nRead our [contributing guide](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Jest.\n\n### [Good First Issues](https://github.com/jestjs/jest/labels/good%20first%20issue)\n\nTo help you get your feet wet and get you familiar with our contribution process, we have a list of [good first issues](https://github.com/jestjs/jest/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started.\n\n## Credits\n\nThis project exists thanks to all the people who [contribute](CONTRIBUTING.md).\n\n\u003ca href=\"https://github.com/jestjs/jest/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/jest/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### [Backers](https://opencollective.com/jest#backer)\n\nThank you to all our backers! 🙏\n\n\u003ca href=\"https://opencollective.com/jest#backers\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/backers.svg?width=890\"\u003e\u003c/a\u003e\n\n### [Sponsors](https://opencollective.com/jest#sponsor)\n\nSupport this project by becoming a sponsor. Your logo will show up here with a link to your website.\n\n\u003ca href=\"https://opencollective.com/jest/sponsor/0/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/0/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/1/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/1/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/2/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/2/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/3/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/3/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/4/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/4/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/5/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/5/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/6/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/6/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/7/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/7/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/8/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/8/avatar.svg\"\u003e\u003c/a\u003e \u003ca href=\"https://opencollective.com/jest/sponsor/9/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/jest/sponsor/9/avatar.svg\"\u003e\u003c/a\u003e\n\n## License\n\nJest is [MIT licensed](./LICENSE).\n\n## Copyright\n\nCopyright Contributors to the Jest project.\n","funding_links":["https://opencollective.com/jest"],"categories":["Testing","TypeScript","Programming","JavaScript框架","facebook","testing","Uncategorized"],"sub_categories":["JavaScript","其他_文本生成、文本对话","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjestjs%2Fjest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjestjs%2Fjest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjestjs%2Fjest/lists"}