<commit_before>## Testing your application

### Used libraries

RSK comes with the following libraries for testing purposes:

* [Mocha](https://mochajs.org/) - Node.js and browser test runner
* [Chai](http://chaijs.com/) - Assertion library
* [Enzyme](https://github.com/airbnb/enzyme) - Testing utilities for React

You may also want to take a look at the following related packages:

* [jsdom](https://github.com/tmpvar/jsdom)
* [react-addons-test-utils](https://www.npmjs.com/package/react-addons-test-utils)

### Running tests

To test your application simply run the
[`yarn test`](https://github.com/kriasoft/react-starter-kit/blob/b22b1810461cec9c53eedffe632a3ce70a6b29a3/package.json#L154)
command which will:

* recursively find all files ending with `.test.js` in your `src/` directory
* mocha execute found files

```bash
yarn test
```

### Conventions

* test filenames MUST end with `test.js` or `yarn test` will not be able to
  detect them
* test filenames SHOULD be named after the related component (e.g. create
  `Login.test.js` for `Login.js` component)

### Basic example

To help you on your way RSK comes with the following
[basic test case](https://github.com/kriasoft/react-starter-kit/blob/master/src/components/Layout/Layout.test.js)
you can use as a starting point:

```js
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import App from '../App';
import Layout from './Layout';

describe('Layout', () => {
  it('renders children correctly', () => {
    const wrapper = shallow(
      <App context={{ insertCss: () => {} }}>
        <Layout>
          <div className="child" />
        </Layout>
      </App>,
    );

    expect(wrapper.contains(<div className="child" />)).to.be.true;
  });
});
```<commit_msg>Updated tests from Mocha and Chai to Jest (#1624)<commit_after>## Testing your application

### Used libraries

RSK comes with the following libraries for testing purposes:

* [Jest](https://facebook.github.io/jest/) - JavaScript testing library
* [Enzyme](https://github.com/airbnb/enzyme) - Testing utilities for React

You may also want to take a look at the following related packages:

* [jsdom](https://github.com/tmpvar/jsdom)
* [react-addons-test-utils](https://www.npmjs.com/package/react-addons-test-utils)

### Running tests

To test your application simply run the
[`yarn test`](https://github.com/kriasoft/react-starter-kit/blob/9014614edcb2f44b23298ca3287b9af3a14b6076/package.json#L152)
command which will:

* recursively find all files ending with `.test.js` in your `src/` directory

```bash
yarn test
```

### Conventions

* test filenames MUST end with `test.js` or `yarn test` will not be able to
  detect them
* test filenames SHOULD be named after the related component (e.g. create
  `Login.test.js` for `Login.js` component)

### Basic example

To help you on your way RSK comes with the following
[basic test case](https://github.com/kriasoft/react-starter-kit/blob/master/src/components/Layout/Layout.test.js)
you can use as a starting point:

```js
import React from 'react';
import renderer from 'react-test-renderer';
import App from '../App';
import Layout from './Layout';

describe('Layout', () => {
  test('renders children correctly', () => {
    const wrapper = renderer
      .create(
        <App context={{ insertCss: () => {}, fetch: () => {}, pathname: '' }}>
          <Layout>
            <div className="child" />
          </Layout>
        </App>,
      )
      .toJSON();

    expect(wrapper).toMatchSnapshot();
  });
});
```
{'fraction_non_alphanumeric': 0.14418473669388904, 'fraction_numerical': 0.01661503801745987, 'mean_word_length': 3.8064952638700946, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 21, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4018237', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1105, 'n_words': 337}