Automation Testing

What Is TestCafe NodeJs Test Automation Framework

By Test Guild
  • Share:
Join the Guild for FREE

A Node.JS Automation Framework

Another open-source testing framework based on nodeJS available to help you create end-to-end function test automation is TestCafe.

How do you know if it's a good choice for your test scenarios?

So, here’s the deal.

Why was TestCafe Created?

I spoke with Julian Bucknall, CTO of DevExpress, the makers of TestCafe, to discuss it on my automation podcast.

First thing I asked was with all the available frameworks already out there why create another one?

DevExpress created TestCafe to handle their custom user interface controls for mobile Web apps.

During that initial automation testing process, they found that they were having a lot of issues testing those controls for mobile devices.

The developers started off trying to use Selenium test scripts, but they were having issues concerning browsers.

Most folks use the latest version of their browsers.

Because DevExpress sells to enterprises, they have to be able to support all the different browsers and versions.

So if a company is using Internet Explorer 9, or whatever it happens to be, they have to be able to say their controls work with IE9. If they don't, they have to fix it.

They also had to have some way of doing regression testing, so that when they did a fix or a new feature it would still run on all the different browsers and versions as well.

IE Browser Automation

TestCafe Support Legacy Versions of Browsers

If you use Selenium, being able to quickly test older browser versions–especially an older version of IE–you may as well give up.

Unfortunately, even in this age, many large companies don't keep up with the latest version of the OS, or a related version of the browser.

In those cases, you still need to be able to quickly and easily run your test against various sets of browsers.

The great thing about TestCafe is that it was created for that exact purpose–to easily support running tests against older browser versions.

So to summarize, it was basically created to support a whole bunch of browsers and all the different legacy versions, because it was a scenario that Selenium couldn’t handle.

TestCafe is Easy to Install

Besides making TestCafe with all the existing browsers and open source, they also wanted it to be easy to install.

It's JavaScript/Node.JS-based, so all you have to do to get started is run:

npm install -g testcafe.

It's also cross-platform and cross-browser and includes built-in reporting functionality.

Does TestCafe Only Work for DevExpress Controls?

Since this tool was created by DevExpress to test their custom controls, you may be wondering whether it only works for applications that use DevExpress controls.

The answer is No. You don't have to use their controls to use TestCafe. It's completely separate.

The bonus is they have excellent open-source documentation as well.

Why Choose TestCafe as your test automation tool of choice?

If you work for a large enterprise and need to support customers that use older browsers, you should definitely give TestCafe a try.

Just like Selenium, it's free and open-source but you don't need to install any other software or web drivers.

For example, to run a test execution again all the browser on my machine all I had to do was create my script Testcafe.js:

import { Selector } from 'testcafe'; // first import testcafe selectors

fixture `Getting Started`// declare the fixture
.page `https://testguild.com/SeleniumTestPage.html`; // specify the start page

//then create a test and place your code there
test('My first test', async t => {
await t
.typeText(Selector("input").withAttribute("name","fname"), 'Joe')
.typeText(Selector("input").withAttribute("name","lname"), 'Colantonio')
.click('#refreshButton')

});

And to run again different browsers I just need to pass the browser to run against in the run command:

TestCafe run test command

testcafe safari Testcafe.js
testcafe firefox Testcafe.js
testcafe chrome Testcafe.js

No need to download any drivers or specify anything in my PATH or pass the path to a driver. Nice and simple. Just the way I like it

I work for a company that has hospital application users who still use IE9, so this would be an excellent tool to check out in this instance.

Another benefit of is that TestCafe uses a smart assertion query mechanism that avoids common flakiness caused by poor scripting of waits in Selenium tests.

As always, there is no perfect tool. Use the tool that works for your team, not what happens to be the most popular tool at the moment.

TestCafe History Origin Story

TestCafe was born out of frustration when developers had issues trying to automate their custom controls using Selenium.

What happened around eight years ago was that they started writing many user interface controls for the web.

Initially, it was just ASP.net.

In essence, server-side applications and some client-side stuff that was going on were relatively minimal, and nobody truly worried about testing that part of it.

They started getting into the HTML 5 and javascript side of things, and there they began to run into issues concerning testing.

Because there are many browsers out there that they had to support, so they need a way to automate their test.

They first tried Selenium without much luck.

So they decided to try it to write their own testing tool for the web for the controls that we were writing.

Because of needing to test frequent releases and had to test mobile, they needed a testing tool that could run on iOS, Safari, and Android, and those were hard to come by back then.

So they created TestCafe and decided it was good enough to sell as a product, and the rest is history.

Why TestCafe is OpenSource

We started selling TestCafe and realized that we had to get the word out about it somehow.

And their first version of testing Cafe worked OK for what they wanted to do. But didn't work pretty well for what other people want to do.

So they had a significant discussion internally and decided that the best bet for us would be to release TestCafe at least the testing part of it as an open-source product.

And basically, try and get everybody we knew to talk about the fact that we were releasing it as an open-source project.

Also, because we have to make a living, to start writing a paid dashboard-type of add on to TestCafe so that it's not necessarily just developers who will use it but also testers.

What The Difference Between the Free Version and The Paid Version?

They are in earnest about this testing tool for testing web applications by making it open source and maintaining it as open source. Making sure it's APIs are open so people can write, for example, plugins and so forth for TestCafe.

On the paid side, they developed a complete user interface to TestCafe so that you don't have to be a super-duper javascript capable and not worry about the command-line interface that's required for the opensource TestCafe.

Julian also mentioned that they wrote it and open-source it, and they still use it everywhere in-house. It's part of their entire continuous build process.

So that's a good sign.

Learn More About The Automation Tool TestCafe

For a deeper dive into this automation tool, be sure to listen to my full interview with Julian Bucknall, CTO of Developer Express.

Also, check out their Github page.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

DevAssure Review: Cut Testing Time Using Low Code Automation?

Posted on 12/11/2024

As you know, testing often becomes a bottleneck in software development due to ...

Leveraging AI and Playwright for Test Case Generation

Posted on 11/22/2024

Two BIG trends the past few years in the software testing space been ...

Symbolic AI vs. Gen AI: The Dynamic Duo in Test Automation

Posted on 09/23/2024

You've probably been having conversations lately about whether to use AI for testing. ...

Automation Guild '25 Online Event - Registration Kickoff Special (Limited Time) - Elevate your E2E testing skills in 2025 >>