• Home
  • Public Speaking
  • Travel
For FE test automation, the E2E frameworks are mostly based on TypeScript (or JavaScript). So better to remember a few tips.

Architecture

We can build test automation code in a reusable way minimizing the duplication. For this purpose, the most common functions are collected in helper classes. Those helper functions can be used in other classes in two ways.

Object Oriented Approach

OOP is kind of traditional way in which the class is instantiated by calling the constructor. In this way, some attributes can already be set and while calling the functions from the class, there is no need to pass the same arguments any more.

Functional Programming

In some cases, there are not too many functions in the class and instead of calling them after creating an instance, directly calling them is more convenient. Functional programming lets us export each function (or any other type module) individually.

Module Management

(See details in article)

NodeJS Standard

CommonJS modules are the standard of NodeJS. A very simple example is as follows:


EMCAScript

EMCAScript (ES6) modules are introduced as the standard of JavaScript. New NodeJS versions already support ES6, but for the old versions it mightbe needed to declare in the config files ("type": "module") In this approach, modules can be exported and imported from different classes. Either named or default exports can be used in ES6.

Default Exports
There can be only one default export in a module, implying the default import. It can be imported with any name. (This great blog describes where to use default and named exports.)

Named Exports
Multiple exports can be done with named exports. In this way, the exact names should be used for the imports. A very simple example is as follows:


Functions

Functions can be declared in several ways, but a modern usage in ES6 is the array functions. (There are differences between regular functions and array functions. See the article for details.) A sample array function is shown below.