jest 33.2K
最后更新于:2022-04-02 03:13:06
[TOC]
> [github](https://github.com/facebook/jest)
> [文档](https://jestjs.io/docs/en/using-matchers#arrays-and-iterables)
## 安装
```
yarn add --dev jest
npm install --save-dev jest
```
## 示例
### hello world
执行 ``` npm run test ```
';
sum.js
``` function sum(a, b) { return a + b; } module.exports = sum; ```sum.test.js
``` const sum = require('./sum'); test('adds 1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); }); ```package.json
``` { "scripts": { "test": "jest" } } ```执行 ``` npm run test ```