diff --git a/README.md b/README.md index 9b7bc3f19..ab1f3ad75 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ The test will be processed in all browsers and **silently** skipped in `ie9`. ### Sharable meta info Implemented via two commands: * setMeta(key, value) -* getMeta(key) +* getMeta([key]) These methods allow you to store some information between webdriver calls and it can then be used in custom commands, for instance. This meta information will be shown in the [allure report](https://github.com/gemini-testing/hermione-allure-reporter). @@ -301,7 +301,9 @@ it('test1', function() { .getMeta('foo') .then((val) => console.log(val)) // prints 'bar' .getMeta('url') - .then((url) => console.log(url)); // prints '/foo/bar?baz=qux' + .then((url) => console.log(url)) // prints '/foo/bar?baz=qux' + .getMeta() + .then((meta) => console.log(meta)) // prints `{foo: 'bar', url: '/foo/bar?baz=qux'}` }); ``` @@ -466,7 +468,7 @@ Option name | Description `screenshotOnRejectTimeout`| Timeout for taking screenshot on test fail. Default value is `httpTimeout`. `testsPerSession` | Maximum amount of tests (`it`s) to run in each web driver session. `retry` | How many times a test should be rerun. Default value is `0`. -`shouldRetry` | Function that determines whether to make a retry. By default returns `true `if retry attempts are available otherwise returns `false`. +`shouldRetry` | Function that determines whether to make a retry. By default returns `true `if retry attempts are available otherwise returns `false`. `calibrate` | Allows to correctly capture the image. Default value is `false`. `screenshotPath` | Directory to save screenshots by Webdriverio. Default value is `null`. `meta` | Additional data that can be obtained via .getMeta() method @@ -512,7 +514,7 @@ Argument of this function is object with fields: * `retriesLeft {Number}` — number of available retries * `ctx` — in case of test `TEST_FAIL` it would be bound data, in case of `ERROR` it would be link to `Runnable` * `[error]` — error type (available only in case of ERROR) - + ### calibrate Does this browser need to perform the calibration procedure. This procedure allows to correctly capture the image in case the particular WebDriver implementation captures browser UI along with web page. Default value is `false`. diff --git a/lib/browser/existing-browser.js b/lib/browser/existing-browser.js index 1f22ce895..dad70f61c 100644 --- a/lib/browser/existing-browser.js +++ b/lib/browser/existing-browser.js @@ -32,7 +32,7 @@ module.exports = class ExistingBrowser extends Browser { _addMetaAccessCommands(session) { session.addCommand('setMeta', (key, value) => this._meta[key] = value); - session.addCommand('getMeta', (key) => this._meta[key]); + session.addCommand('getMeta', (key) => key ? this._meta[key] : this._meta); } _decorateUrlMethod(session) { diff --git a/package-lock.json b/package-lock.json index 315e5d478..f7a2f3083 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hermione", - "version": "0.65.1", + "version": "0.65.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/test/lib/browser/existing-browser.js b/test/lib/browser/existing-browser.js index eaa01306b..1426123ca 100644 --- a/test/lib/browser/existing-browser.js +++ b/test/lib/browser/existing-browser.js @@ -45,6 +45,19 @@ describe('NewBrowser', () => { assert.deepEqual(browser.meta, {k1: 'v1'}); }); + + describe('getMeta', () => { + it('should get all meta if no key provided', async () => { + mkBrowser_(); + + await session.setMeta('foo', 'bar'); + await session.setMeta('baz', 'qux'); + + const meta = await session.getMeta(); + + assert.deepEqual(meta, {foo: 'bar', baz: 'qux'}); + }); + }); }); describe('url decorator', () => {