paint-brush
How to set up functional testing for a web app from scratch in 5 minutesby@amoskovkin
3,063 reads
3,063 reads

How to set up functional testing for a web app from scratch in 5 minutes

by Alexander MoskovkinJanuary 15th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Assume you have a clean PC without any developer <a href="https://hackernoon.com/tagged/tools" target="_blank">tools</a>. How quickly can you install all the required testing tools, write and run your first functional test for the web? An hour? Or two?

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to set up functional testing for a web app from scratch in 5 minutes
Alexander Moskovkin HackerNoon profile picture

Assume you have a clean PC without any developer tools. How quickly can you install all the required testing tools, write and run your first functional test for the web? An hour? Or two?

We at TestCafe think that 5 minutes is more than enough. Seriously.

Start your timer and follow the steps below.

What do I need?

A Windows (Mac or Linux) computer and internet connection.

Node Installation

Install Node.js on your computer. If you are not lucky to have it already installed, google “node.js download”, open the page, download the latest version and install it. A link for the laziest.

TestCafe Installation

Now, your machine is ready to install TestCafe. You can do it from the Node.js package manager (npm) with a single command. Open the console, type in the following text and press Enter:

npm install testcafe -g

Test writing

Let’s write a test. All you need is your favorite text editor. In the example below, we will check whether Google ranks the TestCafe GitHub repository first when searching for “TestCafe on GitHub“.

Create a test.js file in D:\test with the following code:

There is absolutely no magic here.

Test Run

Everything is ready to start the test:

Go to directory D:\test in the console and write a command to open browsers and start the test:

testcafe chrome test.js

Wait until testing is successfully complete and study the test result.


Of course, the amount of time spent at each step can be different depending on the performance of the machine and the Internet connection speed.However, we have completed this tutorial in 4 min 45 sec. And we still have extra 15 seconds :)

Do you have 5 more minutes?

You can run this test in 3 other ways:

  • in any browser installed on your PC — instead of ‘chrome’, write ‘firefox’, ‘edge’, etc. testcafe firefox test.js;
  • in a remote browser on any machine in the local network — instead of ‘chrome’, write ‘remote’ and use the remote machine to open a url that will be displayed testcafe remote test.js;
  • on any mobile device in the local network by simply scanning a QR code (see video) testcafe remote test.js — qr-code.

So, you have spent less than 5 minutes to write your first test. And this is just the beginning because TestCafe has much more useful features to surprise you.