Skip to content

Commit

Permalink
fix: add readme instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
lizaiv77 committed Nov 17, 2020
1 parent 7c544b4 commit e3a135d
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
86 changes: 81 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,83 @@
# utam-example
example of utam integration
Example of utam integration

Steps to run UI tests:
- yarn install
- yarn build
- yarn test
## How to run UI tests in this repo
- `yarn install` installs all dependencies
- `yarn build` compiles Page Objects
- `yarn test` runs test

## Utam dependencies

Utam dependencies to use utam are:
```json
{
"devDependencies": {
"utam": "0.0.1-alpha9",
"wdio-utam-service": "0.0.1-alpha9"
}
}
```

- utam is a compiler and needed to compile POs
- wdio-utam-service is wdio integration, needed for utam to be consumed from any wdio test
Technically wdio-utam-service depends on utam, but we recoomend to explicitely put both.
wdio-utam-service also has dependencies from wdio version 6.6, but we recommend to override those in your package configuration.

Note: at the moment UTAM is indegrated with wdio ver 6.


## Compile POs from json

We do not publish artifact with POs, at the moment it should be set as part of the build.
- copy JSON files to your package with tests inside folder `__utam__`, for example to `packages/myTests/src/__utam__`
- add utam.config.js with `module.exports = {};` at the package root
- add utam compile cli command to build phase:

```json
{
"scripts": {
"build": "yarn compile",
"compile": "utam -c utam.config.js",
"test": "wdio"
}
}
```
- POs will be generated under `<package root>/pageObjects/`

## webdriverio integration and UI tests

- Configure wdio as if you were not using UTAM
- add Utam wdio service:
```
const { UtamWdioService } = require('wdio-utam-service');
...
exports.config = {
...
services: ['chromedriver', [UtamWdioService, {}]]
...
}
```

- inside a spec file
- import utam page object from your target folder
- use global object __utam__ to create/load Utam Page Objects inside your test, ex:

```js
import Login from 'tmp-pageobjects/pageObjects/login';

describe('login test', () => {
beforeAll(() => {
// timeout for UI operations
// temporary, later should be set via service config
browser.setTimeout({ implicit: 30000 });
});

it('app navigation', async () => {
await browser.url('/');
const loginPage = await utam.load(Login);
await loginPage.login('test@kk.org', 'password123456');
...
}
```
> IMPORTANT: all POs methods are asynchronious, remember to use async in tests
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.1-alpha9",
"version": "0.0.1",
"command": {
"publish": {
"forcePublish": "*"
Expand Down
2 changes: 1 addition & 1 deletion packages/tmp-pageobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@wdio/cli": "^6.6.2",
"chromedriver": "^85.0.1",
"ts-node": "^9.0.0",
"utam": "0.0.1-alpha9",
"wdio-chromedriver-service": "^6.0.0",
"utam": "0.0.1-alpha9",
"wdio-utam-service": "0.0.1-alpha9"
}
}

0 comments on commit e3a135d

Please sign in to comment.