npm i -g create-react-app
npm i -g @storybook/cli
create-react-app super-cool-app
cd super-cool-app
getstorybook
(initialise github repo etc)
-- using @storybook/cli instead of storybook because...I couldn't get it working?
Initially running tests throwing an error:
events.js:160
throw er; // Unhandled 'error' event
brew install watchman
yarn test
Why use create-react-app and getstorybook
- Super fast to set up
- Very detailed Documentation
File structure choices
- All components in
src/
- Each component has its own folder, with three files,
index.test.js
,index.js
andstories.js
- This means all tests are next to the relevant components
-
Setup Docker/Makefile
-
when testing components, at what point do you write the storybook? Should you use the storybook as the 'end-to-end' (manual) test, so write it first, then break down into smaller 'unit/component' tests that you use to TDD the code itself?
-
Add enzyme so I can unit test components using shallow - faster tests if not rendering whole DOM?
-
if testing components, does storybook become a duplication of testing?
-
Added enzyme-matchers because
expect(wrapper).toContainReact(welcome)
is so much nicer thanexpect(wrapper.contains(app_name)).toEqual(true);
-
:( no
context
, but there isdescribe
in Jest