August 2, 201610 yr Hey all. I'm building out a project purely for educational purposes, it is yet another todo app, but will have a load of features. The App itself - what it does is kind of irrelevant as it's intentions are to help cement my learning of React, Redux, React-router and how to test such an application with both unit and acceptance tests - where I will be using Ava and NYC I thought I would share the work-in progress repository as I think others can learn from the good things I do in here along with the mistakes I will inevitably make. @@citypaul I am sure you will be able to add some good feedback on how the testing can be improved. This is a WIP that I started a few days ago so you can watch how it gets built out. If anybody has any Qs I'll be happy to answer https://github.com/rbrtsmith/redux-advanced-todo-app
August 2, 201610 yr Author Ava is a JavaScript unit testing framework, I literally started using it today https://github.com/avajs/ava it is quite minimal and runs unit tests concurrently which means if you've a lot of tests they will run much faster. NYC a command line interface for Istanbul https://github.com/gotwarlost/istanbul which is a test coverage suite. Test coverage tells you how much of your code is covered by your unit tests in the terminal, and it is also configured in my project to output a HTML file inside of /coverage/ that will display the results in a more human readable form. I am sure @@citypaul can expand more being the testing guru that he is
August 3, 201610 yr Author Updated. Now have the ability to edit existing todos. Unit tests have been added for this functionality and I have adhered to the write tests first best practice.
August 3, 201610 yr Author One thing to note: You will only see 'class' in one component and no createClass. All other components are functional which should always be prefered unless you need to use a components lifecycle hooks or use state. In the case of this App Redux handles all state. In the case where I used 'class' I have to use the componentDidMount() lifecycle hook. I recommend you do the same. Class is considered an antipattern in JS and unfortunately in my case here React provides no alternative. But they are looking at changing that in future releases...
August 3, 201610 yr Author NPM scripts is fine if you are just running a couple of tasks but things become unweildy as complexity increases. I prefer something like Gulp here. Webpack is good too but I just chose Gulp here. As for testing React components I will ad some tests for them but Dan Abramhov has spoken about not unit testing dumb components and focus more on testing the logic consumed by Redux. Apparently this is why Facebook don't pay much attention to the react-test-utils. Whether or not this is is right or wrong it's what facebook appear to be doing. Although I do plan to add in enzyme and test non-dumb components.
August 3, 201610 yr Author Just pushed up another update. Some basic styling and colour coding todos based on priority level.
August 3, 201610 yr Author Btw I plan to a retro after this project is done covering what went well and what can be improved for my next one
August 3, 201610 yr Thank you very much for sharing this! I think, we need "pinned" theme where forum members can post theirs React app and questions about creating and testing React components.
August 3, 201610 yr Author One of our devs recommended it over nigh****ch. Whats your recommendation?
August 3, 201610 yr Author Ha. Well I'm using nigh****ch at the moment and have found it nicer than webdriver io. I'd be interested in knowing why he/she recommended webdriver io? We use webdriver for some things internally and it's just a massive source of pain for us - the docs are often either wrong or just missing things, often it just doesn't work as documented and the api itself is really inconsistent and just plain nasty to work with. I can tell you I'm certainly not the only person with that opinion in our workplace. I should add that we've only used nigh****ch sparingly for some quite lightweight end to end tests so far, but so far I've preferred it over webdriver. I shall ask him tomorrow, he's used both pretty extensively.
August 3, 201610 yr Author Another update - I've added the ability to add new todos and cleaned up the interface and navigation a little. Tomorrow I plan to look at swapping out some of the text fields for select boxes, and investigate unit testing React components with Enzyme. All of the Redux reducers, action-creators and utility functions are tested.
August 4, 201610 yr Author Added some more updates. Refactored the remove button into its own component so it can be dropped in on both the single todo view and the grid of todods.
August 6, 201610 yr Author Added a preview component inside the <AddTodo /> component which updates the preview todo as you type. Added more unit testing now focusing on the components themselves using Enzyme.https://github.com/rbrtsmith/redux-advanced-todo-app Edited August 6, 201610 yr by rbrtsmith
Create an account or sign in to comment