Skip to content

Commit

Permalink
Updated tests from Mocha and Chai to Jest (kriasoft#1624)
Browse files Browse the repository at this point in the history
* Updated from Mocha to Jest

Still need to update React-intl

* modified tests to jest instead of mocha and chai

* left react-intl example the same due to yarn eval
  • Loading branch information
wwendyc authored and langpavel committed Jun 19, 2018
1 parent 207691c commit 585a821
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions docs/testing-your-application.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

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
* [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:
Expand All @@ -16,11 +15,10 @@ You may also want to take a look at the following related packages:
### Running tests

To test your application simply run the
[`yarn test`](https://github.com/kriasoft/react-starter-kit/blob/b22b1810461cec9c53eedffe632a3ce70a6b29a3/package.json#L154)
[`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
* mocha execute found files

```bash
yarn test
Expand All @@ -41,22 +39,23 @@ you can use as a starting point:

```js
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import renderer from 'react-test-renderer';
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;
test('renders children correctly', () => {
const wrapper = renderer
.create(
<App context={{ insertCss: () => {}, fetch: () => {}, pathname: '' }}>
<Layout>
<div className="child" />
</Layout>
</App>,
)
.toJSON();

expect(wrapper).toMatchSnapshot();
});
});
```
Expand Down

0 comments on commit 585a821

Please sign in to comment.