Testing w/ Puppeteer & Node | Helpfulz

Testing w/ Puppeteer & Node

July 26, 2019

So I had a bit of an experience that I wanted to share. It was my first time putting together a test with Puppeteer, but I have seen a glimpse of the power it has and some of the cool things that you can do with it.

So I have an app that my colleague and I built that helps TA’s at our course keep track of time in the class and help us know when we are ahead or behind of the class schedule.

Essentially you upload an “.xlsx” file and it parses the information from it and makes the plan from there. This is a 6 months minimum course and there are several different forms that the class can take. For example there is a part time class, full time, and an online part time class with their own separate curriculums. So this means that there are a ton of these “.xlsx” files floating around and there are some differences between them. Unfortunately they are not perfectly uniform…

So what this means is that there is a chance that if the information is not in a certain order it can break the app. I ran across this a few times when first building. Now I did my best to catch them all, I quickly glanced over a majority of hte files that we have, but honestly I didn’t have the patience to test all 100+ files one by one.

So, now I have reached a point where I have advertised the product a bit more to my team and I wanted to go back and test it a bit further to ensure reliability. I had heard about Puppeteer from a friend and thought I’d give it a try.

What’s awesome is I was able to build a script that extracted all of the .xlsx files from all classes, there were 206 in total. I was able to use Node to loop through and test every file. It was pretty cool, for every file I had a new headless Chrome Browser load up (in the background of course), load the .xlsx file and then take a screenshot showing if it worked or not.

I could then quickly go through all of the screenshots and see if they all worked or not. I could see within 2 minutes that all of the files worked and the app didn’t have any major issues that I needed to catch for.

That was a really cool feeling to know this. Plus, I was able to build this all out in one day. If I were to go through the files and manually test this, it would take forever and I would have honestly just never done it.

So, while I understand my app isn’t bomb proof, I have a lot more peace of mind having it out there knowing that the app is not likely to crash.

End of story, testing is good and worth your time!

Profile picture

Written by IzzleNizzle who can be found playing around in the mountains of Utah. ⛰️ You should follow Iz on Twitter

© 2022, Built with Gatsby and WordPress