> For the complete documentation index, see [llms.txt](https://gzqsjtu.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gzqsjtu.gitbook.io/workspace/test.md).

# Test

## integration testing

## Unit testing

functional testing

## Jest

we hava a xxx.js

create a xxx.test.js

![](https://4116032991-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LgnugJ0SdX2tMAwP37V%2F-Lhh6SPpD8GePSbPj5Q5%2F-LhhCOs3phLKX_I6c6go%2Fimage.png?alt=media\&token=0908ee78-3db2-44a5-a352-78d0bc5c3b9c)

![](https://4116032991-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LgnugJ0SdX2tMAwP37V%2F-Lhh6SPpD8GePSbPj5Q5%2F-LhhCTGzaULvWj62E8Om%2Fimage.png?alt=media\&token=66a7ee73-c67a-411e-bf82-11b54d4c69e3)

#### Using Babel

To use [Babel](http://babeljs.io/), install required dependencies via `yarn`

"dependencies": { "babel-core": "^6.26.3", "babel-jest": "^23.6.0", "babel-preset-env": "^1.7.0", "jest": "^24.0.0" }

![](https://4116032991-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LgnugJ0SdX2tMAwP37V%2F-Lhh6SPpD8GePSbPj5Q5%2F-LhhChGqfSj8hdG47IAA%2Fimage.png?alt=media\&token=a2df6095-058c-46c1-978a-8340ad95aeae)

#### Using webpack

Jest can be used in projects that use [webpack](https://webpack.github.io/) to manage assets, styles, and compilation.&#x20;

### Common Matchers

The simplest way to test a value is with exact equality.

```
test('two plus two is four', () => {
  expect(2 + 2).toBe(4);
});
```

![](https://4116032991-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LgnugJ0SdX2tMAwP37V%2F-LhharNXG09VDwkikISn%2F-Lhhd2zO5jLydIzFFiL9%2Fimage.png?alt=media\&token=ca26ed3e-ebbc-4e0b-a3ef-d49748a2ec14)

![](https://4116032991-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LgnugJ0SdX2tMAwP37V%2F-LhhkPaeswf4Bh4YL3x3%2F-LhhkQN87OcqfDahc7jx%2Fimage.png?alt=media\&token=a64ec000-d3a3-4cb3-848b-1603a41829bd)

![](https://4116032991-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LgnugJ0SdX2tMAwP37V%2F-LhhkPaeswf4Bh4YL3x3%2F-LhhkUOn-tekf4baFO4F%2Fimage.png?alt=media\&token=6d09f0ef-521f-4446-bbce-850bcf47df02)

&#x20;[**Jasmine**](https://jasmine.github.io/)

```
describe("A suite is just a function", function() {
  var a;

  it("and so is a spec", function() {
    a = true;

    expect(a).toBe(true);
  });
});444444
```

<br>
