An Node.js approach for integrating e2e tests using the Web and Mobile platform together.

Gabriel Salla Galvão Dias
3 min readApr 23, 2020

The motivation for this article was the lack of content related to this subject, that is, cross platform integration of automated tests. In a more informal language, the need for tests to be performed in a web and mobile environment on the same feature, without having to run them separately.

When we are writing automated e2e tests, we end up always creating the idea of a cluster, that is, running only web tests or running only mobile tests at a time.

This need comes to the fore when the features of the system in which we are performing automation, need to navigate between web and mobile platforms using the same scenario.

But first, a summary of what Node.js is:
Node.js is a platform built on the Google Chrome JavaScript engine to easily build fast and scalable network applications. Node.js uses a non-blocking event-driven I/O model that makes it lightweight and efficient, ideal for real-time applications with intense data exchange across distributed devices.

This article is based on a project that uses frameworks like: WebdriverIO, Cucumber, Appium e Typescript.

Usually, we run a web or mobile feature, using specific scripts for each one, for example:

To run the web tests, it is necessary to execute:

npm run test:debug

To run the mobile tests:

npm run app-test

If it is necessary to test the scenario on the web and on mobile, the QA must execute one at a time, thus increasing the time and having intervention during the process.

And how was integration resolved in this case?

The simplest way would be to create a new script in package.json, calling both, something like:

"integration": "npm run test:debug && npm run app-test"

If you need a separate file to have more autonomy in the script, you can choose the following model:

A file was created at the root of the project, called integracao.js and containing the following generic script:

const process = require ("child_process")
function start () { process.execSync("npm run test:debug"); console.log("<<< END OF WEB TESTS >>>") console.log("--------------------------------") process.execSync("npm run app-test") console.log("<<< END OF MOBILE TESTS >>>")}
start ()

The child_process imported into the project allows the creation of child processes, in this case process.execSync.
ExecSync executes the script and, because it is a synchronous process, does not allow the execution of another process until it is completed.

When executing the command node integracao.js in the terminal, according to how the script is written, web tests must be executed first and then mobile tests.

When is it interesting to integrate tests from different platforms?

If your system has interaction between the web and mobile platforms, this practice will help to better validate the data in the tests, so that it is possible to perform information crossings between them. In addition to creating a more robust automation, reducing interventions during the process.

--

--

Gabriel Salla Galvão Dias

I’m QA. I love and work with test automation. Passionate about technology and who is always looking to improve knowledge in the area.