From 585a821ef67aa432fe83b22e57b62f9dcc5b9bd3 Mon Sep 17 00:00:00 2001 From: wwendyc Date: Mon, 18 Jun 2018 22:18:18 -0400 Subject: [PATCH] Updated tests from Mocha and Chai to Jest (#1624) * 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 --- docs/testing-your-application.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/testing-your-application.md b/docs/testing-your-application.md index 4859238da..f0984d5ee 100644 --- a/docs/testing-your-application.md +++ b/docs/testing-your-application.md @@ -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: @@ -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 @@ -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( - {} }}> - -
- - , - ); - - expect(wrapper.contains(
)).to.be.true; + test('renders children correctly', () => { + const wrapper = renderer + .create( + {}, fetch: () => {}, pathname: '' }}> + +
+ + , + ) + .toJSON(); + + expect(wrapper).toMatchSnapshot(); }); }); ```