Agenda

Table of contents

As you might have seen, the Confluence Protractor Base is written in TypeScript. For those of you, who have never seen TypeScript Code, it is more Java like than plain JavaScript. The main advantage are, as the name sais, types. Varibales and method params are typed for example, which leads to safer programming and IDE support. Furthermore, visibilities, inheritance, classes and many other things are easir to write and read. The Typescript code ist transpiled (source-to-source compilation) into valid JavaScript, so it's only used for development.

Requirements

If everything worked fine, you should find a 'build/' directory in your root folder, which contains the transpiled JavaScript files.

Run tests with typescript

Instead of

>>> npm run test-e2e

run

>>> npm run test-e2e-typescript

Which first transpiles the TypeScript code and the runs the tests from the built JavaScript files.

Differences to the JavaScript UI-Tests

The TypeScript tests provide the same structure and do the same things as the JavaScript tests. So if you follow the other parts of the tutorial you know what the files do. The differences will be described here

Configuration

There's a tsconfig.json configuration file in your root directory (see full reference here), which provides compilerOptions and the included TypeScript files. Also there's a linter for TypeScript, which requires a tslint.json. This is all further configuration you need.

Declaring functions

Instead of

JavaScript

function () { }

use

TypeScript

() => { }

This is not only TypeScript but the ES6 standard

Take away

Implementing in TypeScript brings type safety and improved IDE support. Writing page objects and tests it more comfortable, with a lower error rate. If you just start writing your own tests, give it a try!