From e3a135deb3f68ba77ea6232b17b94e9bc47a2a2b Mon Sep 17 00:00:00 2001 From: Elizaveta Ivanova Date: Mon, 16 Nov 2020 17:07:35 -0800 Subject: [PATCH] fix: add readme instruction --- README.md | 86 +++++++++++++++++++++++++-- lerna.json | 2 +- packages/tmp-pageobjects/package.json | 2 +- 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eb968c5..70c4316 100644 --- a/README.md +++ b/README.md @@ -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 `/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 \ No newline at end of file diff --git a/lerna.json b/lerna.json index 8ce0079..403f099 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.0.1-alpha9", + "version": "0.0.1", "command": { "publish": { "forcePublish": "*" diff --git a/packages/tmp-pageobjects/package.json b/packages/tmp-pageobjects/package.json index afe0122..de4970e 100644 --- a/packages/tmp-pageobjects/package.json +++ b/packages/tmp-pageobjects/package.json @@ -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" } }