From b20cc589de7186fc2c9e9216294bb691c8c652c8 Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Sat, 30 Mar 2024 21:56:36 -0700 Subject: [PATCH] update chapter 12 --- solutions/README.md | 2 +- solutions/chapter_02/package.json | 8 +- solutions/chapter_03/package.json | 8 +- solutions/chapter_04/package.json | 8 +- solutions/chapter_05/package.json | 8 +- solutions/chapter_05/wdio.sauce.conf.js | 4 +- solutions/chapter_06/package.json | 2 +- .../chapter_09/perfecto/wdio.local.conf.js | 4 +- .../chapter_09/perfecto/wdio.perfecto.conf.js | 4 +- .../chapter_09/saucelabs/wdio.local.conf.js | 4 +- .../chapter_09/saucelabs/wdio.sauce.conf.js | 4 +- solutions/chapter_10/wdio.local.conf.js | 4 +- solutions/chapter_11/package.json | 4 +- solutions/chapter_11/wdio.applitools.conf.js | 4 +- solutions/chapter_12/package.json | 25 +- .../chapter_12/test/pageobjects/main.page.ts | 4 +- solutions/chapter_12/test/specs/test.ts | 2 +- solutions/chapter_12/tsconfig.json | 13 +- solutions/chapter_12/wdio.conf.ts | 428 +++++++++--------- solutions/chapter_12/wdio.local.conf.ts | 23 +- 20 files changed, 275 insertions(+), 288 deletions(-) diff --git a/solutions/README.md b/solutions/README.md index 072b903..91871ea 100644 --- a/solutions/README.md +++ b/solutions/README.md @@ -1,4 +1,4 @@ Solutions ========= -If you get stuck in one of the chapters you can look in here to see how it was suppose to be done. Every solution for each chapter has a different NPM `package.json` so ensure that you install the dependency before you run the example. +If you get stuck in one of the chapters you can look in here to see how it was supposed to be done. Every solution for each chapter has a different NPM `package.json` so ensure that you install the dependency before you run the example. diff --git a/solutions/chapter_02/package.json b/solutions/chapter_02/package.json index 83dce04..1586058 100644 --- a/solutions/chapter_02/package.json +++ b/solutions/chapter_02/package.json @@ -1,14 +1,14 @@ { "name": "chapter2", "version": "1.0.0", - "description": "", + "description": "Chapter 2 of the WebdriverIO workshop: Writing an automation script using Standalone Mode", + "keywords": [], + "author": "Christian Bromann ", + "license": "MIT", "type": "module", "scripts": { "test": "node test.js" }, - "keywords": [], - "author": "Christian Bromann ", - "license": "MIT", "devDependencies": { "webdriverio": "^8.32.4" } diff --git a/solutions/chapter_03/package.json b/solutions/chapter_03/package.json index 9c90493..456f68f 100644 --- a/solutions/chapter_03/package.json +++ b/solutions/chapter_03/package.json @@ -1,14 +1,14 @@ { "name": "chapter3", "version": "1.0.0", - "description": "", + "description": "Chapter 4 of the WebdriverIO workshop: WDIO Testrunner", "type": "module", - "scripts": { - "test": "wdio wdio.conf.js" - }, "keywords": [], "author": "Christian Bromann ", "license": "MIT", + "scripts": { + "test": "wdio wdio.conf.js" + }, "devDependencies": { "@wdio/cli": "^8.32.4", "@wdio/local-runner": "^8.32.4", diff --git a/solutions/chapter_04/package.json b/solutions/chapter_04/package.json index f1ec161..f9bb932 100644 --- a/solutions/chapter_04/package.json +++ b/solutions/chapter_04/package.json @@ -1,14 +1,14 @@ { "name": "chapter4", "version": "1.0.0", - "description": "", + "description": "Chapter 4 of the WebdriverIO workshop: Use of Reporter and Services", "type": "module", - "scripts": { - "test": "wdio wdio.conf.js" - }, "keywords": [], "author": "Christian Bromann ", "license": "MIT", + "scripts": { + "test": "wdio wdio.conf.js" + }, "devDependencies": { "@wdio/allure-reporter": "^8.32.4", "@wdio/cli": "^8.32.4", diff --git a/solutions/chapter_05/package.json b/solutions/chapter_05/package.json index c659c4f..3cffdca 100644 --- a/solutions/chapter_05/package.json +++ b/solutions/chapter_05/package.json @@ -1,15 +1,15 @@ { "name": "chapter5", "version": "1.0.0", - "description": "", + "description": "Chapter 5 of the WebdriverIO workshop: Performance Testing", + "keywords": [], + "author": "Christian Bromann ", + "license": "MIT", "type": "module", "scripts": { "test": "wdio wdio.conf.js", "test:sauce": "wdio wdio.sauce.conf.js" }, - "keywords": [], - "author": "Christian Bromann ", - "license": "MIT", "devDependencies": { "@wdio/allure-reporter": "^8.32.4", "@wdio/cli": "^8.32.4", diff --git a/solutions/chapter_05/wdio.sauce.conf.js b/solutions/chapter_05/wdio.sauce.conf.js index fb233b7..4ffb826 100644 --- a/solutions/chapter_05/wdio.sauce.conf.js +++ b/solutions/chapter_05/wdio.sauce.conf.js @@ -1,11 +1,11 @@ import url from 'node:url' import path from 'node:path' -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' const __dirname = path.resolve(url.fileURLToPath(new URL('.', import.meta.url))) export const config = { - ...baseConfig, + ...sharedConfig, services: [], specs: [ __dirname + '/test/specs/extra.js' diff --git a/solutions/chapter_06/package.json b/solutions/chapter_06/package.json index cfab059..03ec0f6 100644 --- a/solutions/chapter_06/package.json +++ b/solutions/chapter_06/package.json @@ -1,5 +1,5 @@ { - "name": "chapter5", + "name": "chapter6", "version": "1.0.0", "description": "Chapter 6 of the WebdriverIO workshop: PWA Testing", "keywords": [], diff --git a/solutions/chapter_09/perfecto/wdio.local.conf.js b/solutions/chapter_09/perfecto/wdio.local.conf.js index 1a14579..761bef8 100644 --- a/solutions/chapter_09/perfecto/wdio.local.conf.js +++ b/solutions/chapter_09/perfecto/wdio.local.conf.js @@ -1,9 +1,9 @@ import allure from 'allure-commandline' -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' export const config = { - ...baseConfig, + ...sharedConfig, capabilities: [{ maxInstances: 5, diff --git a/solutions/chapter_09/perfecto/wdio.perfecto.conf.js b/solutions/chapter_09/perfecto/wdio.perfecto.conf.js index e05e80b..406836e 100644 --- a/solutions/chapter_09/perfecto/wdio.perfecto.conf.js +++ b/solutions/chapter_09/perfecto/wdio.perfecto.conf.js @@ -1,4 +1,4 @@ -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' const perfectoOptions = { 'perfecto:options': { @@ -7,7 +7,7 @@ const perfectoOptions = { } export const config = { - ...baseConfig, + ...sharedConfig, /** * Perfecto connection details diff --git a/solutions/chapter_09/saucelabs/wdio.local.conf.js b/solutions/chapter_09/saucelabs/wdio.local.conf.js index 1a14579..761bef8 100644 --- a/solutions/chapter_09/saucelabs/wdio.local.conf.js +++ b/solutions/chapter_09/saucelabs/wdio.local.conf.js @@ -1,9 +1,9 @@ import allure from 'allure-commandline' -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' export const config = { - ...baseConfig, + ...sharedConfig, capabilities: [{ maxInstances: 5, diff --git a/solutions/chapter_09/saucelabs/wdio.sauce.conf.js b/solutions/chapter_09/saucelabs/wdio.sauce.conf.js index b9621f8..5c5fc04 100644 --- a/solutions/chapter_09/saucelabs/wdio.sauce.conf.js +++ b/solutions/chapter_09/saucelabs/wdio.sauce.conf.js @@ -1,4 +1,4 @@ -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' const sauceOptions = { 'sauce:options': { @@ -7,7 +7,7 @@ const sauceOptions = { } export const config = { - ...baseConfig, + ...sharedConfig, /** * Sauce Labs Credentials diff --git a/solutions/chapter_10/wdio.local.conf.js b/solutions/chapter_10/wdio.local.conf.js index f9b244a..9ef1c4e 100644 --- a/solutions/chapter_10/wdio.local.conf.js +++ b/solutions/chapter_10/wdio.local.conf.js @@ -1,9 +1,9 @@ import allure from 'allure-commandline' -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' export const config = { - ...baseConfig, + ...sharedConfig, capabilities: [{ maxInstances: 5, diff --git a/solutions/chapter_11/package.json b/solutions/chapter_11/package.json index 1a2b007..a88ccf4 100644 --- a/solutions/chapter_11/package.json +++ b/solutions/chapter_11/package.json @@ -1,7 +1,7 @@ { - "name": "chapter9", + "name": "chapter11", "version": "1.0.0", - "description": "Chapter 10 of the WebdriverIO workshop: Visual Regression Testing", + "description": "Chapter 11 of the WebdriverIO workshop: Visual Regression Testing", "main": "index.js", "keywords": [], "author": "Christian Bromann ", diff --git a/solutions/chapter_11/wdio.applitools.conf.js b/solutions/chapter_11/wdio.applitools.conf.js index 1673179..bfe43d1 100644 --- a/solutions/chapter_11/wdio.applitools.conf.js +++ b/solutions/chapter_11/wdio.applitools.conf.js @@ -1,9 +1,9 @@ import allure from 'allure-commandline' -import { config as baseConfig } from './wdio.conf.js' +import { config as sharedConfig } from './wdio.conf.js' export const config = { - ...baseConfig, + ...sharedConfig, capabilities: [{ maxInstances: 5, diff --git a/solutions/chapter_12/package.json b/solutions/chapter_12/package.json index c54aaa4..d29c6c6 100644 --- a/solutions/chapter_12/package.json +++ b/solutions/chapter_12/package.json @@ -1,8 +1,7 @@ { - "name": "chapter9", + "name": "chapter12", "version": "1.0.0", - "description": "", - "main": "index.js", + "description": "Chapter 12 of the WebdriverIO workshop: TypeScript", "scripts": { "test": "wdio wdio.local.conf.ts" }, @@ -10,16 +9,14 @@ "author": "Christian Bromann ", "license": "MIT", "devDependencies": { - "@wdio/allure-reporter": "^7.20.3", - "@wdio/cli": "^7.20.4", - "@wdio/local-runner": "^7.20.4", - "@wdio/mocha-framework": "^7.20.3", - "@wdio/spec-reporter": "^7.20.3", - "allure-commandline": "^2.17.2", - "chromedriver": "^103.0.0", - "ts-node": "^10.8.1", - "typescript": "^4.7.4", - "wdio-chromedriver-service": "^7.3.2", - "webdriverio": "^7.20.4" + "@wdio/allure-reporter": "^8.34.0", + "@wdio/cli": "^8.35.1", + "@wdio/local-runner": "^8.35.1", + "@wdio/mocha-framework": "^8.35.0", + "@wdio/spec-reporter": "^8.32.4", + "allure-commandline": "^2.27.0", + "ts-node": "^10.9.2", + "typescript": "^5.4.3", + "webdriverio": "^8.35.1" } } diff --git a/solutions/chapter_12/test/pageobjects/main.page.ts b/solutions/chapter_12/test/pageobjects/main.page.ts index 911f352..29b5bf9 100644 --- a/solutions/chapter_12/test/pageobjects/main.page.ts +++ b/solutions/chapter_12/test/pageobjects/main.page.ts @@ -1,6 +1,6 @@ import TodoEntry from './todo.entry' -class TodoAppPO { +export class TodoAppPageObject { get newTodoInput () { return $('.new-todo') } @@ -37,4 +37,4 @@ class TodoAppPO { } } -export const TodoApp = new TodoAppPO() +export const TodoApp = new TodoAppPageObject() diff --git a/solutions/chapter_12/test/specs/test.ts b/solutions/chapter_12/test/specs/test.ts index 9c19700..0f02885 100644 --- a/solutions/chapter_12/test/specs/test.ts +++ b/solutions/chapter_12/test/specs/test.ts @@ -1,4 +1,4 @@ -const { TodoApp } = require('../pageobjects/main.page') +import { TodoApp } from '../pageobjects/main.page.js' describe('My Vue.js Example Application', () => { it('should be able to complete ToDos', async () => { diff --git a/solutions/chapter_12/tsconfig.json b/solutions/chapter_12/tsconfig.json index f718a0e..372b098 100644 --- a/solutions/chapter_12/tsconfig.json +++ b/solutions/chapter_12/tsconfig.json @@ -4,8 +4,8 @@ /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + "target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ + "module": "NodeNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ @@ -49,10 +49,13 @@ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": [ - "node", "webdriverio/async", "@wdio/mocha-framework", "expect-webdriverio" + "node", + "@wdio/globals/types", + "@wdio/mocha-framework", + "expect-webdriverio" ], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ @@ -67,7 +70,7 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ /* Advanced Options */ - "skipLibCheck": true, /* Skip type checking of declaration files. */ + // "skipLibCheck": false, /* Skip type checking of declaration files. */ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ } } diff --git a/solutions/chapter_12/wdio.conf.ts b/solutions/chapter_12/wdio.conf.ts index ee5161f..b20bd8f 100644 --- a/solutions/chapter_12/wdio.conf.ts +++ b/solutions/chapter_12/wdio.conf.ts @@ -1,218 +1,218 @@ export const config: WebdriverIO.Config = { - /** - * will be overwritten - */ - capabilities: {}, - // - // ================== - // Specify Test Files - // ================== - // Define which test specs should run. The pattern is relative to the directory - // from which `wdio` was called. Notice that, if you are calling `wdio` from an - // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working - // directory is where your package.json resides, so `wdio` will be called from there. - // - specs: [ - './test/specs/**/*.ts' - ], - // Patterns to exclude. - exclude: [ - // 'path/to/excluded/files' - ], - // - // ============ - // Capabilities - // ============ - // Define your capabilities here. WebdriverIO can run multiple capabilities at the same - // time. Depending on the number of capabilities, WebdriverIO launches several test - // sessions. Within your capabilities you can overwrite the spec and exclude options in - // order to group specific specs to a specific capability. - // - // First, you can define how many instances should be started at the same time. Let's - // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have - // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec - // files and you set maxInstances to 10, all spec files will get tested at the same time - // and 30 processes will get spawned. The property handles how many capabilities - // from the same test should run tests. - // - maxInstances: 10, - outputDir: './logs', - // - // =================== - // Test Configurations - // =================== - // Define all options that are relevant for the WebdriverIO instance here - // - // Level of logging verbosity: trace | debug | info | warn | error | silent - logLevel: 'trace', - // - // Set specific log levels per logger - // loggers: - // - webdriver, webdriverio - // - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service - // - @wdio/mocha-framework, @wdio/jasmine-framework - // - @wdio/local-runner, @wdio/lambda-runner - // - @wdio/sumologic-reporter - // - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils - // Level of logging verbosity: trace | debug | info | warn | error | silent - // logLevels: { - // webdriver: 'info', - // '@wdio/applitools-service': 'info' - // }, - // - // If you only want to run your tests until a specific amount of tests have failed use - // bail (default is 0 - don't bail, run all tests). - bail: 0, - // - // Set a base URL in order to shorten url command calls. If your `url` parameter starts - // with `/`, the base url gets prepended, not including the path portion of your baseUrl. - // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url - // gets prepended directly. - baseUrl: 'http://todomvc.com/examples/vue/dist/', - // - // Default timeout for all waitFor* commands. - waitforTimeout: 10000, - // - // Default timeout in milliseconds for request - // if Selenium Grid doesn't send response - connectionRetryTimeout: 90000, - // - // Default request retries count - connectionRetryCount: 3, - // - // Test runner services - // Services take over a specific job you don't want to take care of. They enhance - // your test setup with almost no effort. Unlike plugins, they don't add new - // commands. Instead, they hook themselves up into the test process. - // services: [], - // Framework you want to run your specs with. - // The following are supported: Mocha, Jasmine, and Cucumber - // see also: https://webdriver.io/docs/frameworks.html - // - // Make sure you have the wdio adapter package for the specific framework installed - // before running any tests. - framework: 'mocha', - // - // The number of times to retry the entire specfile when it fails as a whole - // specFileRetries: 1, - // - // Test reporter for stdout. - // The only one supported by default is 'dot' - // see also: https://webdriver.io/docs/dot-reporter.html - reporters: [ - 'spec', - ['allure', { - outputDir: 'allure-results' - }] - ], - // - // Options to be passed to Mocha. - // See the full list at http://mochajs.org/ - mochaOpts: { - ui: 'bdd', - timeout: 60000 - }, - // - // ===== - // Hooks - // ===== - // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance - // it and to build services around it. You can either apply a single function or an array of - // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got - // resolved to continue. - /** - * Gets executed once before all workers get launched. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - */ - // onPrepare: function (config, capabilities) { - // }, - /** - * Gets executed just before initialising the webdriver session and test framework. It allows you - * to manipulate configurations depending on the capability or spec. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - */ - // beforeSession: function (config, capabilities, specs) { - // }, - /** - * Gets executed before test execution begins. At this point you can access to all global - * variables like `browser`. It is the perfect place to define custom commands. - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that are to be run - */ - // before: function (capabilities, specs) { - // }, - /** - * Runs before a WebdriverIO command gets executed. - * @param {String} commandName hook command name - * @param {Array} args arguments that command would receive - */ - // beforeCommand: function (commandName, args) { - // }, + /** + * will be overwritten + */ + capabilities: {}, + // + // ================== + // Specify Test Files + // ================== + // Define which test specs should run. The pattern is relative to the directory + // from which `wdio` was called. Notice that, if you are calling `wdio` from an + // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working + // directory is where your package.json resides, so `wdio` will be called from there. + // + specs: [ + './test/specs/**/*.ts' + ], + // Patterns to exclude. + exclude: [ + // 'path/to/excluded/files' + ], + // + // ============ + // Capabilities + // ============ + // Define your capabilities here. WebdriverIO can run multiple capabilities at the same + // time. Depending on the number of capabilities, WebdriverIO launches several test + // sessions. Within your capabilities you can overwrite the spec and exclude options in + // order to group specific specs to a specific capability. + // + // First, you can define how many instances should be started at the same time. Let's + // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have + // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec + // files and you set maxInstances to 10, all spec files will get tested at the same time + // and 30 processes will get spawned. The property handles how many capabilities + // from the same test should run tests. + // + maxInstances: 10, + outputDir: './logs', + // + // =================== + // Test Configurations + // =================== + // Define all options that are relevant for the WebdriverIO instance here + // + // Level of logging verbosity: trace | debug | info | warn | error | silent + logLevel: 'trace', + // + // Set specific log levels per logger + // loggers: + // - webdriver, webdriverio + // - @wdio/applitools-service, @wdio/browserstack-service, @wdio/devtools-service, @wdio/sauce-service + // - @wdio/mocha-framework, @wdio/jasmine-framework + // - @wdio/local-runner, @wdio/lambda-runner + // - @wdio/sumologic-reporter + // - @wdio/cli, @wdio/config, @wdio/sync, @wdio/utils + // Level of logging verbosity: trace | debug | info | warn | error | silent + // logLevels: { + // webdriver: 'info', + // '@wdio/applitools-service': 'info' + // }, + // + // If you only want to run your tests until a specific amount of tests have failed use + // bail (default is 0 - don't bail, run all tests). + bail: 0, + // + // Set a base URL in order to shorten url command calls. If your `url` parameter starts + // with `/`, the base url gets prepended, not including the path portion of your baseUrl. + // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url + // gets prepended directly. + baseUrl: 'http://todomvc.com/examples/vue/dist/', + // + // Default timeout for all waitFor* commands. + waitforTimeout: 10000, + // + // Default timeout in milliseconds for request + // if Selenium Grid doesn't send response + connectionRetryTimeout: 90000, + // + // Default request retries count + connectionRetryCount: 3, + // + // Test runner services + // Services take over a specific job you don't want to take care of. They enhance + // your test setup with almost no effort. Unlike plugins, they don't add new + // commands. Instead, they hook themselves up into the test process. + // services: [], + // Framework you want to run your specs with. + // The following are supported: Mocha, Jasmine, and Cucumber + // see also: https://webdriver.io/docs/frameworks.html + // + // Make sure you have the wdio adapter package for the specific framework installed + // before running any tests. + framework: 'mocha', + // + // The number of times to retry the entire specfile when it fails as a whole + // specFileRetries: 1, + // + // Test reporter for stdout. + // The only one supported by default is 'dot' + // see also: https://webdriver.io/docs/dot-reporter.html + reporters: [ + 'spec', + ['allure', { + outputDir: 'allure-results' + }] + ], + // + // Options to be passed to Mocha. + // See the full list at http://mochajs.org/ + mochaOpts: { + ui: 'bdd', + timeout: 60000 + }, + // + // ===== + // Hooks + // ===== + // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance + // it and to build services around it. You can either apply a single function or an array of + // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got + // resolved to continue. + /** + * Gets executed once before all workers get launched. + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + */ + // onPrepare: function (config, capabilities) { + // }, + /** + * Gets executed just before initialising the webdriver session and test framework. It allows you + * to manipulate configurations depending on the capability or spec. + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + */ + // beforeSession: function (config, capabilities, specs) { + // }, + /** + * Gets executed before test execution begins. At this point you can access to all global + * variables like `browser`. It is the perfect place to define custom commands. + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that are to be run + */ + // before: function (capabilities, specs) { + // }, + /** + * Runs before a WebdriverIO command gets executed. + * @param {String} commandName hook command name + * @param {Array} args arguments that command would receive + */ + // beforeCommand: function (commandName, args) { + // }, - /** - * Hook that gets executed before the suite starts - * @param {Object} suite suite details - */ - // beforeSuite: function (suite) { - // }, - /** - * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts. - * @param {Object} test test details - */ - // beforeTest: function (test) { - // }, - /** - * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling - * beforeEach in Mocha) - */ - // beforeHook: function () { - // }, - /** - * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling - * afterEach in Mocha) - */ - // afterHook: function () { - // }, - /** - * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts. - * @param {Object} test test details - */ - // afterTest: function (test) { - // }, - /** - * Hook that gets executed after the suite has ended - * @param {Object} suite suite details - */ - // afterSuite: function (suite) { - // }, + /** + * Hook that gets executed before the suite starts + * @param {Object} suite suite details + */ + // beforeSuite: function (suite) { + // }, + /** + * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts. + * @param {Object} test test details + */ + // beforeTest: function (test) { + // }, + /** + * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling + * beforeEach in Mocha) + */ + // beforeHook: function () { + // }, + /** + * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling + * afterEach in Mocha) + */ + // afterHook: function () { + // }, + /** + * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts. + * @param {Object} test test details + */ + // afterTest: function (test) { + // }, + /** + * Hook that gets executed after the suite has ended + * @param {Object} suite suite details + */ + // afterSuite: function (suite) { + // }, - /** - * Runs after a WebdriverIO command gets executed - * @param {String} commandName hook command name - * @param {Array} args arguments that command would receive - * @param {Number} result 0 - command success, 1 - command error - * @param {Object} error error object if any - */ - // afterCommand: function (commandName, args, result, error) { - // }, - /** - * Gets executed after all tests are done. You still have access to all global variables from - * the test. - * @param {Number} result 0 - test pass, 1 - test fail - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // after: function (result, capabilities, specs) { - // }, - /** - * Gets executed right after terminating the webdriver session. - * @param {Object} config wdio configuration object - * @param {Array.} capabilities list of capabilities details - * @param {Array.} specs List of spec file paths that ran - */ - // afterSession: function (config, capabilities, specs) { - // } + /** + * Runs after a WebdriverIO command gets executed + * @param {String} commandName hook command name + * @param {Array} args arguments that command would receive + * @param {Number} result 0 - command success, 1 - command error + * @param {Object} error error object if any + */ + // afterCommand: function (commandName, args, result, error) { + // }, + /** + * Gets executed after all tests are done. You still have access to all global variables from + * the test. + * @param {Number} result 0 - test pass, 1 - test fail + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // after: function (result, capabilities, specs) { + // }, + /** + * Gets executed right after terminating the webdriver session. + * @param {Object} config wdio configuration object + * @param {Array.} capabilities list of capabilities details + * @param {Array.} specs List of spec file paths that ran + */ + // afterSession: function (config, capabilities, specs) { + // } } diff --git a/solutions/chapter_12/wdio.local.conf.ts b/solutions/chapter_12/wdio.local.conf.ts index ecfe4c0..d2d5b68 100644 --- a/solutions/chapter_12/wdio.local.conf.ts +++ b/solutions/chapter_12/wdio.local.conf.ts @@ -2,27 +2,14 @@ import allure from 'allure-commandline' import { config as sharedConfig } from './wdio.conf' -export const config: WebdriverIO.Config = Object.assign(sharedConfig, { +export const config: WebdriverIO.Config = { + ...sharedConfig, + capabilities: [{ - // maxInstances can get overwritten per capability. So if you have an in-house Selenium - // grid with only 5 firefox instances available you can make sure that not more than - // 5 instances get started at a time. maxInstances: 5, - // browserName: 'chrome' - // If outputDir is provided WebdriverIO can capture driver session logs - // it is possible to configure which logTypes to include/exclude. - // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs - // excludeDriverLogs: ['bugreport', 'server'], }], - services: [ - [ - 'chromedriver', - { outputDir: './logs' } - ] - ], - /** * Gets executed after all workers got shut down and the process is about to exit. * @param {Object} exitCode 0 - success, 1 - fail @@ -30,7 +17,7 @@ export const config: WebdriverIO.Config = Object.assign(sharedConfig, { * @param {Array.} capabilities list of capabilities details * @param {} results object containing test results */ - onComplete: function() { + onComplete: () => { const generation = allure(['generate', 'allure-results']) return new Promise((resolve, reject) => { const generationTimeout = setTimeout( @@ -44,4 +31,4 @@ export const config: WebdriverIO.Config = Object.assign(sharedConfig, { }) }) } -}) +}