| Notes so far: Run `npm test` which uses `react-scripts test` which in turn uses `jest` for testing. There's no need to install `jest` in the dependencies as it's bundled in react-scripts I faced some problems with running the initial App.test.js that comes with create-react-app
import React from 'react'; |
import ReactDOM from 'react-dom'; |
import App from './App'; |
|
it('renders without crashing', () => { |
const div = document.createElement('div'); |
ReactDOM.render(<App />, div); |
});
|
Caused the following error
or pass a custom React context provider to <Provider> and the corresponding React context consumer to connect in connect options
|
The problem is that mounting the App component in the test mounts all nested components. The solution which is described here is to shallow render the components which can be done by using packages `enzyme` and `enzyme-adapter-react-16` 16 relating to the current version of React being used by the project. I have a test successfully running which does a shallow render on the App component which contains a basic smoke test that the app doesn't crash when it renders. Progressing now to What unit tests we could/should implement here. David Ffrench Wei Li in terms of integration tests what would be looking for here? Also what's implemented in MDC, would it be valuable to base our testing approach here on MDC's testing approach? |