diff --git a/docs/helpers/REST.md b/docs/helpers/REST.md index deb1c2578..14d166479 100644 --- a/docs/helpers/REST.md +++ b/docs/helpers/REST.md @@ -14,25 +14,21 @@ title: REST REST helper allows to send additional requests to the REST API during acceptance tests. [Axios][1] library is used to perform requests. - - ## Configuration Type: [object][4] ### Properties -* `endpoint` **[string][3]?** API base URL -* `prettyPrintJson` **[boolean][6]?** pretty print json for response/request on console logs. -* `printCurl` **[boolean][6]?** print cURL request on console logs. False by default. -* `timeout` **[number][5]?** timeout for requests in milliseconds. 10000ms by default. -* `defaultHeaders` **[object][4]?** a list of default headers. -* `httpAgent` **[object][4]?** create an agent with SSL certificate -* `onRequest` **[function][7]?** an async function which can update request object. -* `onResponse` **[function][7]?** an async function which can update response object. -* `maxUploadFileSize` **[number][5]?** set the max content file size in MB when performing api calls. - - +- `endpoint` **[string][3]?** API base URL +- `prettyPrintJson` **[boolean][6]?** pretty print json for response/request on console logs. +- `printCurl` **[boolean][6]?** print cURL request on console logs. False by default. +- `timeout` **[number][5]?** timeout for requests in milliseconds. 10000ms by default. +- `defaultHeaders` **[object][4]?** a list of default headers. +- `httpAgent` **[object][4]?** create an agent with SSL certificate +- `onRequest` **[function][7]?** an async function which can update request object. +- `onResponse` **[function][7]?** an async function which can update response object. +- `maxUploadFileSize` **[number][5]?** set the max content file size in MB when performing api calls. ## Example @@ -91,34 +87,34 @@ Send REST requests by accessing `_executeRequest` method: ```js this.helpers['REST']._executeRequest({ - url, - data, -}); + url, + data, +}) ``` ## Methods ### Parameters -* `config` +- `config` -### _executeRequest +### \_executeRequest Executes axios request #### Parameters -* `request` **any** +- `request` **any** Returns **[Promise][2]** response -### _url +### \_url Generates url based on format sent (takes endpoint + url if latter lacks 'http') #### Parameters -* `url` **any** +- `url` **any** ### amBearerAuthenticated @@ -131,7 +127,7 @@ I.amBearerAuthenticated(secret('heregoestoken')) #### Parameters -* `accessToken` **([string][3] | CodeceptJS.Secret)** Bearer access token +- `accessToken` **([string][3] | CodeceptJS.Secret)** Bearer access token ### haveRequestHeaders @@ -139,20 +135,20 @@ Sets request headers for all requests of this test #### Parameters -* `headers` **[object][4]** headers list +- `headers` **[object][4]** headers list ### sendDeleteRequest Sends DELETE request to API. ```js -I.sendDeleteRequest('/api/users/1'); +I.sendDeleteRequest('/api/users/1') ``` #### Parameters -* `url` **any** -* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object +- `url` **any** +- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object Returns **[Promise][2]** response @@ -161,14 +157,14 @@ Returns **[Promise][2]** response Sends DELETE request to API with payload. ```js -I.sendDeleteRequestWithPayload('/api/users/1', { author: 'john' }); +I.sendDeleteRequestWithPayload('/api/users/1', { author: 'john' }) ``` #### Parameters -* `url` **any** -* `payload` **any** the payload to be sent. By default it is sent as an empty object -* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object +- `url` **any** +- `payload` **any** the payload to be sent. By default it is sent as an empty object +- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object Returns **[Promise][2]** response @@ -177,13 +173,28 @@ Returns **[Promise][2]** response Send GET request to REST API ```js -I.sendGetRequest('/api/users.json'); +I.sendGetRequest('/api/users.json') ``` #### Parameters -* `url` **any** -* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object +- `url` **any** +- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object + +Returns **[Promise][2]** response + +### sendHeadRequest + +Send HEAD request to REST API + +```js +I.sendHeadRequest('/api/users.json') +``` + +#### Parameters + +- `url` **any** +- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object Returns **[Promise][2]** response @@ -192,18 +203,17 @@ Returns **[Promise][2]** response Sends PATCH request to API. ```js -I.sendPatchRequest('/api/users.json', { "email": "user@user.com" }); +I.sendPatchRequest('/api/users.json', { email: 'user@user.com' }) // To mask the payload in logs -I.sendPatchRequest('/api/users.json', secret({ "email": "user@user.com" })); - +I.sendPatchRequest('/api/users.json', secret({ email: 'user@user.com' })) ``` #### Parameters -* `url` **[string][3]** -* `payload` **any** the payload to be sent. By default it is sent as an empty object -* `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object +- `url` **[string][3]** +- `payload` **any** the payload to be sent. By default it is sent as an empty object +- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object Returns **[Promise][2]** response @@ -212,18 +222,17 @@ Returns **[Promise][2]** response Sends POST request to API. ```js -I.sendPostRequest('/api/users.json', { "email": "user@user.com" }); +I.sendPostRequest('/api/users.json', { email: 'user@user.com' }) // To mask the payload in logs -I.sendPostRequest('/api/users.json', secret({ "email": "user@user.com" })); - +I.sendPostRequest('/api/users.json', secret({ email: 'user@user.com' })) ``` #### Parameters -* `url` **any** -* `payload` **any** the payload to be sent. By default, it is sent as an empty object -* `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object +- `url` **any** +- `payload` **any** the payload to be sent. By default, it is sent as an empty object +- `headers` **[object][4]** the headers object to be sent. By default, it is sent as an empty object Returns **[Promise][2]** response @@ -232,18 +241,17 @@ Returns **[Promise][2]** response Sends PUT request to API. ```js -I.sendPutRequest('/api/users.json', { "email": "user@user.com" }); +I.sendPutRequest('/api/users.json', { email: 'user@user.com' }) // To mask the payload in logs -I.sendPutRequest('/api/users.json', secret({ "email": "user@user.com" })); - +I.sendPutRequest('/api/users.json', secret({ email: 'user@user.com' })) ``` #### Parameters -* `url` **[string][3]** -* `payload` **any** the payload to be sent. By default it is sent as an empty object -* `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object +- `url` **[string][3]** +- `payload` **any** the payload to be sent. By default it is sent as an empty object +- `headers` **[object][4]** the headers object to be sent. By default it is sent as an empty object Returns **[Promise][2]** response @@ -252,23 +260,17 @@ Returns **[Promise][2]** response Set timeout for the request ```js -I.setRequestTimeout(10000); // In milliseconds +I.setRequestTimeout(10000) // In milliseconds ``` #### Parameters -* `newTimeout` **[number][5]** timeout in milliseconds +- `newTimeout` **[number][5]** timeout in milliseconds [1]: https://github.com/axios/axios - [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise - [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object - [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number - [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean - [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function diff --git a/docs/plugins.md b/docs/plugins.md index b3b20de8a..d7aad9de8 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -1,6 +1,6 @@ --- permalink: plugins -sidebarDepth: +sidebarDepth: sidebar: auto title: Plugins --- @@ -24,42 +24,42 @@ exports.config = { enabled: true, clusterize: 5, analyze: 2, - vision: false - } - } + vision: false, + }, + }, } ``` #### Configuration -* `clusterize` (number) - minimum number of failures to trigger clustering analysis. Default: 5 -* `analyze` (number) - maximum number of individual test failures to analyze in detail. Default: 2 -* `vision` (boolean) - enables visual analysis of test screenshots. Default: false -* `categories` (array) - list of failure categories for classification. Defaults to: - * Browser connection error / browser crash - * Network errors (server error, timeout, etc) - * HTML / page elements (not found, not visible, etc) - * Navigation errors (404, etc) - * Code errors (syntax error, JS errors, etc) - * Library & framework errors - * Data errors (password incorrect, invalid format, etc) - * Assertion failures - * Other errors -* `prompts` (object) - customize AI prompts for analysis - * `clusterize` - prompt for clustering analysis - * `analyze` - prompt for individual test analysis +- `clusterize` (number) - minimum number of failures to trigger clustering analysis. Default: 5 +- `analyze` (number) - maximum number of individual test failures to analyze in detail. Default: 2 +- `vision` (boolean) - enables visual analysis of test screenshots. Default: false +- `categories` (array) - list of failure categories for classification. Defaults to: + - Browser connection error / browser crash + - Network errors (server error, timeout, etc) + - HTML / page elements (not found, not visible, etc) + - Navigation errors (404, etc) + - Code errors (syntax error, JS errors, etc) + - Library & framework errors + - Data errors (password incorrect, invalid format, etc) + - Assertion failures + - Other errors +- `prompts` (object) - customize AI prompts for analysis + - `clusterize` - prompt for clustering analysis + - `analyze` - prompt for individual test analysis #### Features -* Groups similar failures when number of failures >= clusterize value -* Provides detailed analysis of individual failures -* Analyzes screenshots if vision=true and screenshots are available -* Classifies failures into predefined categories -* Suggests possible causes and solutions +- Groups similar failures when number of failures >= clusterize value +- Provides detailed analysis of individual failures +- Analyzes screenshots if vision=true and screenshots are available +- Classifies failures into predefined categories +- Suggests possible causes and solutions ### Parameters -* `config` **[Object][1]** Plugin configuration (optional, default `{}`) +- `config` **[Object][1]** Plugin configuration (optional, default `{}`) Returns **void** @@ -81,28 +81,28 @@ If a session expires automatically logs in again. ```js // inside a test file // use login to inject auto-login function -Feature('Login'); +Feature('Login') Before(({ login }) => { - login('user'); // login using user session -}); + login('user') // login using user session +}) // Alternatively log in for one scenario. -Scenario('log me in', ( { I, login } ) => { - login('admin'); - I.see('I am logged in'); -}); +Scenario('log me in', ({ I, login }) => { + login('admin') + I.see('I am logged in') +}) ``` #### Configuration -* `saveToFile` (default: false) - save cookies to file. Allows to reuse session between execution. -* `inject` (default: `login`) - name of the login function to use -* `users` - an array containing different session names and functions to: - * `login` - sign in into the system - * `check` - check that user is logged in - * `fetch` - to get current cookies (by default `I.grabCookie()`) - * `restore` - to set cookies (by default `I.amOnPage('/'); I.setCookie(cookie)`) +- `saveToFile` (default: false) - save cookies to file. Allows to reuse session between execution. +- `inject` (default: `login`) - name of the login function to use +- `users` - an array containing different session names and functions to: + - `login` - sign in into the system + - `check` - check that user is logged in + - `fetch` - to get current cookies (by default `I.grabCookie()`) + - `restore` - to set cookies (by default `I.amOnPage('/'); I.setCookie(cookie)`) #### How It Works @@ -253,7 +253,7 @@ auth: { ``` ```js -Scenario('login', async ( {I, login} ) => { +Scenario('login', async ({ I, login }) => { await login('admin') // you should use `await` }) ``` @@ -287,14 +287,14 @@ auth: { ``` ```js -Scenario('login', async ( {I, login} ) => { +Scenario('login', async ({ I, login }) => { await login('admin') // you should use `await` }) ``` ### Parameters -* `config` +- `config` ## autoDelay @@ -309,32 +309,32 @@ It puts a tiny delay for before and after action commands. Commands affected (by default): -* `click` -* `fillField` -* `checkOption` -* `pressKey` -* `doubleClick` -* `rightClick` +- `click` +- `fillField` +- `checkOption` +- `pressKey` +- `doubleClick` +- `rightClick` #### Configuration ```js plugins: { - autoDelay: { - enabled: true - } + autoDelay: { + enabled: true + } } ``` Possible config options: -* `methods`: list of affected commands. Can be overridden -* `delayBefore`: put a delay before a command. 100ms by default -* `delayAfter`: put a delay after a command. 200ms by default +- `methods`: list of affected commands. Can be overridden +- `delayBefore`: put a delay before a command. 100ms by default +- `delayAfter`: put a delay after a command. 200ms by default ### Parameters -* `config` +- `config` ## commentStep @@ -343,16 +343,16 @@ This plugin is **deprecated**, use `Section` instead. Add descriptive nested steps for your tests: ```js -Scenario('project update test', async (I) => { - __`Given`; - const projectId = await I.have('project'); +Scenario('project update test', async I => { + __`Given` + const projectId = await I.have('project') - __`When`; - projectPage.update(projectId, { title: 'new title' }); + __`When` + projectPage.update(projectId, { title: 'new title' }) - __`Then`; - projectPage.open(projectId); - I.see('new title', 'h1'); + __`Then` + projectPage.open(projectId) + I.see('new title', 'h1') }) ``` @@ -372,8 +372,8 @@ This plugin can be used ### Config -* `enabled` - (default: false) enable a plugin -* `registerGlobal` - (default: false) register `__` template literal function globally. You can override function global name by providing a name as a value. +- `enabled` - (default: false) enable a plugin +- `registerGlobal` - (default: false) register `__` template literal function globally. You can override function global name by providing a name as a value. ### Examples @@ -414,11 +414,11 @@ For instance, you can prepare Given/When/Then functions to use them inside tests ```js // inside a test -const step = codeceptjs.container.plugins('commentStep'); +const step = codeceptjs.container.plugins('commentStep') -const Given = () => step`Given`; -const When = () => step`When`; -const Then = () => step`Then`; +const Given = () => step`Given` +const When = () => step`When` +const Then = () => step`Then` ``` Scenario('project update test', async (I) => { @@ -434,11 +434,20 @@ I.see('new title', 'h1'); }); ``` + ``` ### Parameters -* `config` +- `config` + +## consolidateWorkerJsonResults + +Consolidates JSON reports from multiple workers into a single HTML report + +### Parameters + +- `config` ## coverage @@ -459,15 +468,15 @@ plugins: { Possible config options, More could be found at [monocart-coverage-reports][2] -* `debug`: debug info. By default, false. -* `name`: coverage report name. -* `outputDir`: path to coverage report. -* `sourceFilter`: filter the source files. -* `sourcePath`: option to resolve a custom path. +- `debug`: debug info. By default, false. +- `name`: coverage report name. +- `outputDir`: path to coverage report. +- `sourceFilter`: filter the source files. +- `sourcePath`: option to resolve a custom path. ### Parameters -* `config` +- `config` ## customLocator @@ -487,11 +496,11 @@ This plugin will create a valid XPath locator for you. #### Configuration -* `enabled` (default: `false`) should a locator be enabled -* `prefix` (default: `$`) sets a prefix for a custom locator. -* `attribute` (default: `data-test-id`) to set an attribute to be matched. -* `strategy` (default: `xpath`) actual locator strategy to use in query (`css` or `xpath`). -* `showActual` (default: false) show in the output actually produced XPath or CSS locator. By default shows custom locator value. +- `enabled` (default: `false`) should a locator be enabled +- `prefix` (default: `$`) sets a prefix for a custom locator. +- `attribute` (default: `data-test-id`) to set an attribute to be matched. +- `strategy` (default: `xpath`) actual locator strategy to use in query (`css` or `xpath`). +- `showActual` (default: false) show in the output actually produced XPath or CSS locator. By default shows custom locator value. #### Examples: @@ -510,8 +519,8 @@ plugins: { In a test: ```js -I.seeElement('$user'); // matches => [data-test=user] -I.click('$sign-up'); // matches => [data-test=sign-up] +I.seeElement('$user') // matches => [data-test=user] +I.click('$sign-up') // matches => [data-test=sign-up] ``` Using `data-qa` attribute with `=` prefix: @@ -530,8 +539,8 @@ plugins: { In a test: ```js -I.seeElement('=user'); // matches => [data-qa=user] -I.click('=sign-up'); // matches => [data-qa=sign-up] +I.seeElement('=user') // matches => [data-qa=user] +I.click('=sign-up') // matches => [data-qa=sign-up] ``` Using `data-qa` OR `data-test` attribute with `=` prefix: @@ -551,8 +560,8 @@ plugins: { In a test: ```js -I.seeElement('=user'); // matches => //*[@data-qa=user or @data-test=user] -I.click('=sign-up'); // matches => //*[data-qa=sign-up or @data-test=sign-up] +I.seeElement('=user') // matches => //*[@data-qa=user or @data-test=user] +I.click('=sign-up') // matches => //*[data-qa=sign-up or @data-test=sign-up] ``` ```js @@ -570,13 +579,13 @@ plugins: { In a test: ```js -I.seeElement('=user'); // matches => [data-qa=user],[data-test=user] -I.click('=sign-up'); // matches => [data-qa=sign-up],[data-test=sign-up] +I.seeElement('=user') // matches => [data-qa=user],[data-test=user] +I.click('=sign-up') // matches => [data-qa=sign-up],[data-test=sign-up] ``` ### Parameters -* `config` +- `config` ## customReporter @@ -584,7 +593,7 @@ Sample custom reporter for CodeceptJS. ### Parameters -* `config` +- `config` ## eachElement @@ -592,17 +601,17 @@ Provides `eachElement` global function to iterate over found elements to perform `eachElement` takes following args: -* `purpose` - the goal of an action. A comment text that will be displayed in output. -* `locator` - a CSS/XPath locator to match elements -* `fn(element, index)` - **asynchronous** function which will be executed for each matched element. +- `purpose` - the goal of an action. A comment text that will be displayed in output. +- `locator` - a CSS/XPath locator to match elements +- `fn(element, index)` - **asynchronous** function which will be executed for each matched element. Example of usage: ```js // this example works with Playwright and Puppeteer helper -await eachElement('click all checkboxes', 'form input[type=checkbox]', async (el) => { - await el.click(); -}); +await eachElement('click all checkboxes', 'form input[type=checkbox]', async el => { + await el.click() +}) ``` Click odd elements: @@ -610,18 +619,18 @@ Click odd elements: ```js // this example works with Playwright and Puppeteer helper await eachElement('click odd buttons', '.button-select', async (el, index) => { - if (index % 2) await el.click(); -}); + if (index % 2) await el.click() +}) ``` Check all elements for visibility: ```js // this example works with Playwright and Puppeteer helper -const assert = require('assert'); -await eachElement('check all items are visible', '.item', async (el) => { - assert(await el.isVisible()); -}); +const assert = require('assert') +await eachElement('check all items are visible', '.item', async el => { + assert(await el.isVisible()) +}) ``` This method works with WebDriver, Playwright, Puppeteer, Appium helpers. @@ -629,28 +638,39 @@ This method works with WebDriver, Playwright, Puppeteer, Appium helpers. Function parameter `el` represents a matched element. Depending on a helper API of `el` can be different. Refer to API of corresponding browser testing engine for a complete API list: -* [Playwright ElementHandle][4] -* [Puppeteer][5] -* [webdriverio element][6] +- [Playwright ElementHandle][4] +- [Puppeteer][5] +- [webdriverio element][6] #### Configuration -* `registerGlobal` - to register `eachElement` function globally, true by default +- `registerGlobal` - to register `eachElement` function globally, true by default If `registerGlobal` is false you can use eachElement from the plugin: ```js -const eachElement = codeceptjs.container.plugins('eachElement'); +const eachElement = codeceptjs.container.plugins('eachElement') ``` ### Parameters -* `purpose` **[string][7]** -* `locator` **CodeceptJS.LocatorOrString** -* `fn` **[Function][8]** +- `purpose` **[string][7]** +- `locator` **CodeceptJS.LocatorOrString** +- `fn` **[Function][8]** Returns **([Promise][9]\ | [undefined][10])** +## enhancedRetryFailedStep + +Enhanced retryFailedStep plugin that coordinates with other retry mechanisms + +This plugin provides step-level retries and coordinates with global retry settings +to avoid conflicts and provide predictable behavior. + +### Parameters + +- `config` + ## fakerTransform Use the `@faker-js/faker` package to generate fake data inside examples on your gherkin tests @@ -669,9 +689,9 @@ Add this plugin to config file: ```js plugins: { - fakerTransform: { - enabled: true - } + fakerTransform: { + enabled: true + } } ``` @@ -689,7 +709,7 @@ Scenario Outline: ... ### Parameters -* `config` +- `config` ## heal @@ -707,11 +727,11 @@ plugins: { More config options are available: -* `healLimit` - how many steps can be healed in a single test (default: 2) +- `healLimit` - how many steps can be healed in a single test (default: 2) ### Parameters -* `config` (optional, default `{}`) +- `config` (optional, default `{}`) ## htmlReporter @@ -770,12 +790,12 @@ plugins: { Additional config options: -* `errorClasses` - list of classes to search for errors (default: `['error', 'warning', 'alert', 'danger']`) -* `browserLogs` - list of types of errors to search for in browser logs (default: `['error']`) +- `errorClasses` - list of classes to search for errors (default: `['error', 'warning', 'alert', 'danger']`) +- `browserLogs` - list of types of errors to search for in browser logs (default: `['error']`) ### Parameters -* `config` (optional, default `{}`) +- `config` (optional, default `{}`) ## pauseOnFail @@ -803,9 +823,9 @@ Add this plugin to config file: ```js plugins: { - retryFailedStep: { - enabled: true - } + retryFailedStep: { + enabled: true + } } ``` @@ -815,22 +835,22 @@ Run tests with plugin enabled: #### Configuration: -* `retries` - number of retries (by default 3), -* `when` - function, when to perform a retry (accepts error as parameter) -* `factor` - The exponential factor to use. Default is 1.5. -* `minTimeout` - The number of milliseconds before starting the first retry. Default is 1000. -* `maxTimeout` - The maximum number of milliseconds between two retries. Default is Infinity. -* `randomize` - Randomizes the timeouts by multiplying with a factor from 1 to 2. Default is false. -* `defaultIgnoredSteps` - an array of steps to be ignored for retry. Includes: - * `amOnPage` - * `wait*` - * `send*` - * `execute*` - * `run*` - * `have*` -* `ignoredSteps` - an array for custom steps to ignore on retry. Use it to append custom steps to ignored list. - You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`. - To append your own steps to ignore list - copy and paste a default steps list. Regexp values are accepted as well. +- `retries` - number of retries (by default 3), +- `when` - function, when to perform a retry (accepts error as parameter) +- `factor` - The exponential factor to use. Default is 1.5. +- `minTimeout` - The number of milliseconds before starting the first retry. Default is 1000. +- `maxTimeout` - The maximum number of milliseconds between two retries. Default is Infinity. +- `randomize` - Randomizes the timeouts by multiplying with a factor from 1 to 2. Default is false. +- `defaultIgnoredSteps` - an array of steps to be ignored for retry. Includes: + - `amOnPage` + - `wait*` + - `send*` + - `execute*` + - `run*` + - `have*` +- `ignoredSteps` - an array for custom steps to ignore on retry. Use it to append custom steps to ignored list. + You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`. + To append your own steps to ignore list - copy and paste a default steps list. Regexp values are accepted as well. #### Example @@ -854,13 +874,21 @@ Use scenario configuration to disable plugin for a test ```js Scenario('scenario tite', { disableRetryFailedStep: true }, () => { - // test goes here + // test goes here }) ``` ### Parameters -* `config` +- `config` + +## safeJsonStringify + +Safely serialize data to JSON, handling circular references + +### Parameters + +- `data` ## screenshotOnFail @@ -876,20 +904,20 @@ Configuration can either be taken from a corresponding helper (deprecated) or a ```js plugins: { - screenshotOnFail: { - enabled: true - } + screenshotOnFail: { + enabled: true + } } ``` Possible config options: -* `uniqueScreenshotNames`: use unique names for screenshot. Default: false. -* `fullPageScreenshots`: make full page screenshots. Default: false. +- `uniqueScreenshotNames`: use unique names for screenshot. Default: false. +- `fullPageScreenshots`: make full page screenshots. Default: false. ### Parameters -* `config` +- `config` ## selenoid @@ -946,7 +974,7 @@ This is especially useful for Continous Integration server as you can configure 1. Create `browsers.json` file in the same directory `codecept.conf.js` is located [Refer to Selenoid documentation][16] to know more about browsers.json. -*Sample browsers.json* +_Sample browsers.json_ ```js { @@ -1006,7 +1034,7 @@ When `allure` plugin is enabled a video is attached to report automatically. ### Parameters -* `config` +- `config` ## stepByStepReport @@ -1032,17 +1060,17 @@ Run tests with plugin enabled: Possible config options: -* `deleteSuccessful`: do not save screenshots for successfully executed tests. Default: true. -* `animateSlides`: should animation for slides to be used. Default: true. -* `ignoreSteps`: steps to ignore in report. Array of RegExps is expected. Recommended to skip `grab*` and `wait*` steps. -* `fullPageScreenshots`: should full page screenshots be used. Default: false. -* `output`: a directory where reports should be stored. Default: `output`. -* `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false. -* \`disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true. +- `deleteSuccessful`: do not save screenshots for successfully executed tests. Default: true. +- `animateSlides`: should animation for slides to be used. Default: true. +- `ignoreSteps`: steps to ignore in report. Array of RegExps is expected. Recommended to skip `grab*` and `wait*` steps. +- `fullPageScreenshots`: should full page screenshots be used. Default: false. +- `output`: a directory where reports should be stored. Default: `output`. +- `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false. +- \`disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true. ### Parameters -* `config` **any** +- `config` **any** ## stepTimeout @@ -1052,9 +1080,9 @@ Add this plugin to config file: ```js plugins: { - stepTimeout: { - enabled: true - } + stepTimeout: { + enabled: true + } } ``` @@ -1064,19 +1092,18 @@ Run tests with plugin enabled: #### Configuration: -* `timeout` - global step timeout, default 150 seconds - -* `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false +- `timeout` - global step timeout, default 150 seconds -* `noTimeoutSteps` - an array of steps with no timeout. Default: +- `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false - * `amOnPage` - * `wait*` +- `noTimeoutSteps` - an array of steps with no timeout. Default: + - `amOnPage` + - `wait*` - you could set your own noTimeoutSteps which would replace the default one. + you could set your own noTimeoutSteps which would replace the default one. -* `customTimeoutSteps` - an array of step actions with custom timeout. Use it to override or extend noTimeoutSteps. - You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`. +- `customTimeoutSteps` - an array of step actions with custom timeout. Use it to override or extend noTimeoutSteps. + You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`. #### Example @@ -1099,7 +1126,7 @@ plugins: { ### Parameters -* `config` +- `config` ## subtitles @@ -1109,9 +1136,9 @@ Automatically captures steps as subtitle, and saves it as an artifact when a vid ```js plugins: { - subtitles: { - enabled: true - } + subtitles: { + enabled: true + } } ``` @@ -1121,11 +1148,11 @@ Webdriverio services runner. This plugin allows to run webdriverio services like: -* selenium-standalone -* sauce -* testingbot -* browserstack -* appium +- selenium-standalone +- sauce +- testingbot +- browserstack +- appium A complete list of all available services can be found on [webdriverio website][20]. @@ -1173,59 +1200,38 @@ plugins: { } ``` -*** +--- In the same manner additional services from webdriverio can be installed, enabled, and configured. #### Configuration -* `services` - list of enabled services -* ... - additional configuration passed into services. +- `services` - list of enabled services +- ... - additional configuration passed into services. ### Parameters -* `config` +- `config` [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object - [2]: https://github.com/cenfun/monocart-coverage-reports?tab=readme-ov-file#default-options - [3]: https://codecept.io/locators#custom-locators - [4]: https://playwright.dev/docs/api/class-elementhandle - [5]: https://pptr.dev/#?product=Puppeteer&show=api-class-elementhandle - [6]: https://webdriver.io/docs/api - [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String - [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function - [9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise - [10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined - [11]: https://codecept.io/heal/ - [12]: /basics/#pause - [13]: https://aerokube.com/selenoid/ - [14]: https://aerokube.com/cm/latest/ - [15]: https://hub.docker.com/u/selenoid - [16]: https://aerokube.com/selenoid/latest/#_prepare_configuration - [17]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container - [18]: https://docs.docker.com/engine/reference/commandline/create/ - [19]: https://codecept.io/img/codeceptjs-slideshow.gif - [20]: https://webdriver.io - [21]: https://webdriver.io/docs/selenium-standalone-service.html - [22]: https://webdriver.io/docs/sauce-service.html diff --git a/lib/helper/REST.js b/lib/helper/REST.js index ba7e10602..db3cc2252 100644 --- a/lib/helper/REST.js +++ b/lib/helper/REST.js @@ -281,6 +281,27 @@ class REST extends Helper { return this._executeRequest(request) } + /** + * Send HEAD request to REST API + * + * ```js + * I.sendHeadRequest('/api/users.json'); + * ``` + * + * @param {*} url + * @param {object} [headers={}] - the headers object to be sent. By default, it is sent as an empty object + * + * @returns {Promise<*>} response + */ + async sendHeadRequest(url, headers = {}) { + const request = { + baseURL: this._url(url), + method: 'HEAD', + headers, + } + return this._executeRequest(request) + } + /** * Sends POST request to API. *