diff --git a/bin/codecept.js b/bin/codecept.js index 9a0ff7db0..06b116e65 100755 --- a/bin/codecept.js +++ b/bin/codecept.js @@ -32,7 +32,7 @@ const commandFlags = { } const errorHandler = - (fn) => + fn => async (...args) => { try { await fn(...args) @@ -286,7 +286,7 @@ program .action(require('../lib/command/run-rerun')) -program.on('command:*', (cmd) => { +program.on('command:*', cmd => { console.log(`\nUnknown command ${cmd}\n`) program.outputHelp() }) diff --git a/docs/helpers/Nightmare.md b/docs/helpers/Nightmare.md index 12727861e..43f6d013f 100644 --- a/docs/helpers/Nightmare.md +++ b/docs/helpers/Nightmare.md @@ -22,28 +22,28 @@ Requires `nightmare` package to be installed. This helper should be configured in codecept.conf.ts or codecept.conf.js -* `url` - base url of website to be tested -* `restart` - restart browser between tests. -* `disableScreenshots` - don't save screenshot on failure. -* `uniqueScreenshotNames` - option to prevent screenshot override if you have scenarios with the same name in different suites. -* `fullPageScreenshots` - make full page screenshots on failure. -* `keepBrowserState` - keep browser state between tests when `restart` set to false. -* `keepCookies` - keep cookies between tests when `restart` set to false. -* `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 500. -* `waitForTimeout`: (optional) default wait* timeout in ms. Default: 1000. -* `windowSize`: (optional) default window size. Set a dimension like `640x480`. +- `url` - base url of website to be tested +- `restart` - restart browser between tests. +- `disableScreenshots` - don't save screenshot on failure. +- `uniqueScreenshotNames` - option to prevent screenshot override if you have scenarios with the same name in different suites. +- `fullPageScreenshots` - make full page screenshots on failure. +- `keepBrowserState` - keep browser state between tests when `restart` set to false. +- `keepCookies` - keep cookies between tests when `restart` set to false. +- `waitForAction`: (optional) how long to wait after click, doubleClick or PressKey actions in ms. Default: 500. +- `waitForTimeout`: (optional) default wait\* timeout in ms. Default: 1000. +- `windowSize`: (optional) default window size. Set a dimension like `640x480`. -* options from [Nightmare configuration][2] +- options from [Nightmare configuration][2] ## Methods ### Parameters -* `config` +- `config` -### _locate +### \_locate Locate elements by different locator types, including strict locator. Should be used in custom helpers. @@ -55,17 +55,17 @@ client-side function: ```js // get an inner text of an element -let browser = this.helpers['Nightmare'].browser; -let value = this.helpers['Nightmare']._locate({name: 'password'}).then(function(els) { - return browser.evaluate(function(el) { - return codeceptjs.fetchElement(el).value; - }, els[0]); -}); +let browser = this.helpers['Nightmare'].browser +let value = this.helpers['Nightmare']._locate({ name: 'password' }).then(function (els) { + return browser.evaluate(function (el) { + return codeceptjs.fetchElement(el).value + }, els[0]) +}) ``` #### Parameters -* `locator` +- `locator` ### amOnPage @@ -73,15 +73,15 @@ Opens a web page in a browser. Requires relative or absolute url. If url starts with `/`, opens a web page of a site defined in `url` config parameter. ```js -I.amOnPage('/'); // opens main page of website -I.amOnPage('https://github.com'); // opens github -I.amOnPage('/login'); // opens a login page +I.amOnPage('/') // opens main page of website +I.amOnPage('https://github.com') // opens github +I.amOnPage('/login') // opens a login page ``` #### Parameters -* `url` **[string][3]** url path or global url. -* `headers` **[object][4]?** list of request headers can be passed +- `url` **[string][3]** url path or global url. +- `headers` **[object][4]?** list of request headers can be passed Returns **void** automatically synchronized promise through #recorder @@ -91,15 +91,15 @@ Appends text to a input field or textarea. Field is located by name, label, CSS or XPath ```js -I.appendField('#myTextField', 'appended'); +I.appendField('#myTextField', 'appended') // typing secret -I.appendField('password', secret('123456')); +I.appendField('password', secret('123456')) ``` #### Parameters -* `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator -* `value` **[string][3]** text value to append. +- `field` **([string][3] | [object][4])** located by label|name|CSS|XPath|strict locator +- `value` **[string][3]** text value to append. Returns **void** automatically synchronized promise through #recorder @@ -110,14 +110,14 @@ Path to file is relative current codecept directory (where codecept.conf.ts or c File will be uploaded to remote system (if tests are running remotely). ```js -I.attachFile('Avatar', 'data/avatar.jpg'); -I.attachFile('form input[name=avatar]', 'data/avatar.jpg'); +I.attachFile('Avatar', 'data/avatar.jpg') +I.attachFile('form input[name=avatar]', 'data/avatar.jpg') ``` #### Parameters -* `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator. -* `pathToFile` **[string][3]** local file path relative to codecept.conf.ts or codecept.conf.js config file. +- `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator. +- `pathToFile` **[string][3]** local file path relative to codecept.conf.ts or codecept.conf.js config file. Returns **void** automatically synchronized promise through #recorderDoesn't work if the Chromium DevTools panel is open (as Chromium allows only one attachment to the debugger at a time. [See more][5]) @@ -129,15 +129,15 @@ Element is located by label or name or CSS or XPath. The second parameter is a context (CSS or XPath locator) to narrow the search. ```js -I.checkOption('#agree'); -I.checkOption('I Agree to Terms and Conditions'); -I.checkOption('agree', '//form'); +I.checkOption('#agree') +I.checkOption('I Agree to Terms and Conditions') +I.checkOption('agree', '//form') ``` #### Parameters -* `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator. -* `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator. +- `field` **([string][3] | [object][4])** checkbox located by label | name | CSS | XPath | strict locator. +- `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator. Returns **void** automatically synchronized promise through #recorder @@ -147,28 +147,28 @@ Clears a cookie by name, if none provided clears all cookies. ```js -I.clearCookie(); -I.clearCookie('test'); +I.clearCookie() +I.clearCookie('test') ``` #### Parameters -* `cookie` **[string][3]?** (optional, `null` by default) cookie name +- `cookie` **[string][3]?** (optional, `null` by default) cookie name ### clearField Clears a `