Some people despise developing with unit tests, but I prefer to use them and leverage them to the allow me to quickly push new code and be more confident that it works! I love doing TDD (test-driven development) which inherently involves continuously re-running the tests, and regardless of what language you are coding in, being able to run your tests in "watch mode" makes TDD faster and easier than without it!
Pro Tip: Use Async / Await With Act To Avoid Act Warnings in Jest / Enzyme Tests And Have Components Update Properly!
I was having a hard time recently writing jest + enzyme unit tests for a react.js project, and one of my colleagues saved the day with the await / async addition. In this post I'll go through what I was doing, what I tried that didn't work, and what we ultimately went with that fixed everything!
My team and I are working on a React project that runs in regular browsers, and we recently decided to use Cypress for end to end testing. It has an actually surprisingly nice you can use to write describe-it style test scripts that will load up a browser with any page on your site, click some things, interact with the dom, and then even do assertions that your page renders correctly. You can do "cypress run" to run your tests via the command line or "cypress open" to start this little application from which you can run all tests or just specific tests, and it creates this little sidebar that gives you a history of the commands it's running and details about what happened when things have failed. Anyway, yes Cypress is awesome, but that's not what thing blog post was supposed to be about...
As a professional software developer I have had the luxury of being able to work on successful professional projects in AngularJS, React, and now the modern Angular. To me it's so funny how similar the two frameworks are in terms of the problem they are trying to solve and even the way they do it.
Well guys, I learned a cool new thing today! Did you know about the "it.only" syntax in mocha? Can you believe I just discovered it today?! Yep, my life has forever changed for the better now that I'm aware of in.only, and since you're reading this post right now I hope it will change yours too!
The posts on this site are written and maintained by Jim Lynch. About Jim...
Want FREE access to
my daily stock tips
"The Triple Gainers"?
Sign up here!