E2E Testing with Testcafe

Jun 17, 2019

I started a new job at the beginning of the year which has contributed to my lack of blogging, but is also the impetus for exploring some new automation frameworks. I'd settled into using Protractor at my last job, but was interested to take a peek at any new tools that had popped up in the last few years... which is how I found Testcafe, a great, open source, E2E test framework.

Take a peek at my github account, you'll see that I often port a handful of dorky, example tests over to various test frameworks to get a sense for them. And now you'll find my port to Testcafe there as well. Porting these tests gives me a real sense of what makes a framework tick; the good and the bad.

Testcafe has a number of interesting features but the one that immediately caught my eye was implicit waits (ie. the framework handles waiting for page/element loading). For anyone who has written their own explicit waits (in which waiting for things is your problem), implicit wait would likely be very compelling! I feel like at some point, the industry decided that implicit waits were bad... I disagreed with that then and I disagree with it now. Implicit waits save a TON of time and assuming the framework offers a reasonable way to handle negative cases (eg. that an element does not exist), we're all good. YMMV...

Another interesting feature is it does not use Webdriver. Probably like most people, I have a love-hate relationship with Webdriver: love what it can do; hate the bugs/inconsistencies in the various browser implementations. Testcafe (similar to Sahi) uses a proxy to inject test code into the browser. Personally, I don't care how a tool makes the sausage... I just care that it does work and [SPOILER:], it works!

Of course Testcafe also hits on a number of goodies:

But it was when I was porting my example testcases to Tescafe, that I found the best feature of all... the community. Simply Googling for testcafe [shplah] almost every time returned pertinent results for the questions I had. They have great documentation, an active community forum, and a fine showing on stackoverflow.

So in my new position, I spiked out a few small projects in Testcafe and another leading Webdriver framework and posed it to my team to choose. Testcafe won out!