diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ebb8df..c7c0b71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## [Unreleased] - :rocket: added source maps +- :rocket: improved readability of execute steps ## [2.3.0] - :rocket: added `I expect {value} css property of every element in {playwrightLocator} collection {validation} {value}` step diff --git a/src/execute.ts b/src/execute.ts index 9bc8eb8..cb5224c 100644 --- a/src/execute.ts +++ b/src/execute.ts @@ -8,7 +8,7 @@ import {Locator} from "@playwright/test"; * @example I execute '$fn' function // fn is function reference * @example I execute 'window.scrollBy(0, 100)' function */ -When('I execute {value} function', async function (fn: MemoryValue) { +When('I execute {value} function/script', async function (fn: MemoryValue) { await this.playwright.page.evaluate(await fn.value()); }); @@ -19,7 +19,7 @@ When('I execute {value} function', async function (fn: MemoryValue) { * @example I execute '$fn' function and save result as 'result' // fn is function reference * @example I execute 'window.scrollY' function and save result as 'scroll' */ -When('I execute {value} function and save result as {value}', async function (fn: MemoryValue, memoryKey: MemoryValue) { +When('I execute {value} function/script and save result as {value}', async function (fn: MemoryValue, memoryKey: MemoryValue) { memoryKey.set(await this.playwright.page.evaluate(await fn.value())); }); @@ -30,7 +30,7 @@ When('I execute {value} function and save result as {value}', async function (fn * @example I execute '$fn' function on 'Component > Element' // fn is function reference * @example I execute 'arguments[0].scrollIntoView()' function on 'Component > Element' */ -When('I execute {value} function on {playwrightLocator}', async function (fnKey: MemoryValue, locator: Locator) { +When('I execute {value} function/script on {playwrightLocator}', async function (fnKey: MemoryValue, locator: Locator) { let fn = await fnKey.value(); if (typeof fn === 'string') { fn = new Function('return ' + fn) @@ -46,7 +46,7 @@ When('I execute {value} function on {playwrightLocator}', async function (fnKey: * @example I execute 'arguments[0].innerText' function on 'Component > Element' and save result as 'innerText' */ When( - 'I execute {value} function on {playwrightLocator} and save result as {value}', + 'I execute {value} function/script on {playwrightLocator} and save result as {value}', async function (fnKey: MemoryValue, locator: Locator, memoryKey: MemoryValue) { let fn = await fnKey.value(); if (typeof fn === 'string') { diff --git a/test-e2e/features/execute.feature b/test-e2e/features/execute.feature index 15a8508..cc3409d 100644 --- a/test-e2e/features/execute.feature +++ b/test-e2e/features/execute.feature @@ -8,7 +8,7 @@ Feature: execute Then I expect 'value' property of 'Input' to be equal 'some value' Scenario: execute function - When I execute '$setInputValue' function + When I execute '$setInputValue' script Then I expect 'value' property of 'Input' to be equal 'some value' Scenario: execute function and save result plain text @@ -18,7 +18,7 @@ Feature: execute Scenario: execute function from memory and save result plain text When I click 'Button' - When I execute '$getActionInnerText' function and save result as 'innerText' + When I execute '$getActionInnerText' script and save result as 'innerText' Then I expect '$innerText' memory value to be equal 'click' Scenario: execute function on element plain text @@ -30,7 +30,7 @@ Feature: execute Then I expect text of 'Action' to be equal 'click' Scenario: execute function on element plain text and save result - When I execute 'arguments[0].innerText' function on 'Button' and save result as 'buttonInnerText' + When I execute 'arguments[0].innerText' script on 'Button' and save result as 'buttonInnerText' Then I expect '$buttonInnerText' memory value to be equal 'Click Me!' Scenario: execute function on element and save result