Testcafe and Testcafe installation

Sonal Sorte
3 min readDec 12, 2021


Hi Readers,

I know it has been too long since my last blog, but I have started writing again and this time I have come up with a technical blog.

I tried my hands on an end-to-end testing automation tool named ‘Testcafe’ (new to me) which is similar to Cyperss.io, a well-known tool used in UI automation. And I found that there are many reasons for which I vote Testcafe as a user-friendly automation tool. I list them as below:

1. Testcafe is open-source and is actively maintained with in-house support

2. No 3rd party dependencies, like those you have while using Selenium. You do not worry about those version compatibilities

3. Human readable .js tests, you can use Testcafe with the least knowledge of JavaScript

4. You can Switch between different iframes easily

5. Automated waits i.e., Built-in wait mechanism (will be explained in further blogs in detail)

Etc…. and many more.

In my today’s blog I have explained the installation process of Testcafe and some pre-requisite installations required for the same:

I. Node.js installation — to write tests in Typescripts/Java Scripts: https://nodejs.org/en/download/

II. VS Code installation — IDE: https://code.visualstudio.com/download

III. Git extension (optional)– if you are using a shared codebase: http://gitextensions.github.io/

Testcafe installation:

Testcafe can be installed from npm in 3 ways:

1. Global installation

2. Local installation

3. Ad hoc installation

Global installation:

· Global installation is used to run the Testcafe in the command line.

· Installation process:

o Type in the following command in the command line:

npm install -g testcafe

o After this, use the following testcafe command to run it from the command line

Testcafe chrome tests/

Local installation:

· Local installation should be preferred following reasons:

o For a continuous integration system

o Node.js application

o Other scenarios where global installation is not required

· Benefits of local installation are:

o It makes your project easier, as the npm install when executed in the project directory, installs all dependencies including the Testcafe

o Different projects can use different versions of testcafe

· Installation process:

o Type in the following command in the command line:

npm install –save -dev testcafe

Now there are 3 ways in which you can run Testcafe locally:

a. Using npx command:

npx testcafe chrome test/

b. Using yarn run:

yarn run testcafe chrome tests/

c. Using npm script:


“test”: “testcafe chrome tests/”


Now use the npm test to run the specified testcafe command:

npm test

Note: If the Testcafe is installed both globally and locally then the testcafe command runs the local version

i.e. Testcafe chrome tests/

Ad Hoc Installation:

· This approach is usually not recommended for regular use.

· As the npx utility installs the modules required to run the specified command and if these modules are not installed globally or in the local project, then we use npx testcafe, this is needed to quickly run testcafe from a directory outside the project

npx testcafe chrome tests/

I have used the global installation of the Testcafe in my project as I found it much easier to use.

My next blog will be on the Test structure and Global functions of Testcafe. So, stay tuned for more blogs on Testcafe, and till then…

Stay Home!

Stay Safe!