Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated tests from Mocha and Chai to Jest #1624

Merged
merged 3 commits into from
Jun 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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