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!
Once again I'm saved by friends in the Clojurians slack channel! This time it was viebel who answered my question in the klipse room. I really love the simplicity and ease of app.klipse.tech because it gives you an instant Clojurescript scratchpad at your fingertips. My only issue was that I didn't know how to add other ClojureScript libraries. Viebel opened my eyes to the fact that it's actually incredicibly easy to add other Clojurescript libraries, and here's how you do it!
The posts on this site are written and maintained by Jim Lynch. About Jim...