Linux command
jest 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run all tests
jest
Run specific test file
jest [path/to/test.js]
Run tests matching pattern
jest -t "[pattern]"
Run in watch mode
jest --watch
Generate coverage report
jest --coverage
Update snapshots
jest -u
Run tests in parallel
jest --maxWorkers=[4]
Run only changed tests
jest --onlyChanged
说明
jest is a JavaScript testing framework with focus on simplicity. It provides test runners, assertions, mocking, and code coverage in a single package. The tool features snapshot testing, parallel execution, and intelligent test selection. It works with React, Vue, Node.js, and most JavaScript projects.
参数
- --watch
- Watch mode for changed files.
- --watchAll
- Watch all files.
- --coverage
- Collect code coverage.
- -t _pattern_
- Run matching test names.
- -u, --updateSnapshot
- Update snapshots.
- --maxWorkers _n_
- Max parallel workers.
- --onlyChanged
- Run only changed tests.
- --bail
- Stop on first failure.
- --verbose
- Display individual test results.
- --config _file_
- Configuration file.
- --ci
- CI mode settings.
FAQ
What is the jest command used for?
jest is a JavaScript testing framework with focus on simplicity. It provides test runners, assertions, mocking, and code coverage in a single package. The tool features snapshot testing, parallel execution, and intelligent test selection. It works with React, Vue, Node.js, and most JavaScript projects.
How do I run a basic jest example?
Run `jest` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --watch do in jest?
Watch mode for changed files.