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
!Screenshot 2019-02-20 at 13.37.00.png|thumbnail!
I faced some problems with running the initial App.test.js that comes with create-react-app
{code} 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); }); {code}
Caused the following error
{code} or pass a custom React context provider to <Provider> and the corresponding React context consumer to connect in connect options {code}
The problem is that mounting the App component in the test mounts all nested components.
The solution which is described [here|https://facebook.github.io/create-react-app/docs/running-tests#option-1-shallow-rendering] 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.
[~dffrench] [~weili] 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?
|
|