# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gzqsjtu.gitbook.io/workspace/test.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
