From 4e36506b41b21013e9ccbb4e9784e8192ae4fbd7 Mon Sep 17 00:00:00 2001 From: jancorvus <> Date: Mon, 21 Jun 2021 20:04:31 +0300 Subject: [PATCH 1/3] Content of Before/After/All hooks will be logged in Allure report now --- lib/plugin/allure.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/plugin/allure.js b/lib/plugin/allure.js index e6b64d21a..789d5fe5d 100644 --- a/lib/plugin/allure.js +++ b/lib/plugin/allure.js @@ -83,7 +83,6 @@ module.exports = (config) => { let currentMetaStep = []; let currentStep; - let isHookSteps = false; reporter.pendingCase = function (testName, timestamp, opts = {}) { reporter.startCase(testName, timestamp); @@ -191,14 +190,6 @@ module.exports = (config) => { } }); - event.dispatcher.on(event.hook.started, () => { - isHookSteps = true; - }); - - event.dispatcher.on(event.hook.passed, () => { - isHookSteps = false; - }); - event.dispatcher.on(event.suite.after, () => { reporter.endSuite(); }); @@ -258,15 +249,13 @@ module.exports = (config) => { }); event.dispatcher.on(event.step.started, (step) => { - if (isHookSteps === false) { - startMetaStep(step.metaStep); - if (currentStep !== step) { - // In multi-session scenarios, actors' names will be highlighted with ANSI - // escape sequences which are invalid XML values - step.actor = step.actor.replace(ansiRegExp(), ''); - reporter.startStep(step.toString()); - currentStep = step; - } + startMetaStep(step.metaStep); + if (currentStep !== step) { + // In multi-session scenarios, actors' names will be highlighted with ANSI + // escape sequences which are invalid XML values + step.actor = step.actor.replace(ansiRegExp(), ''); + reporter.startStep(step.toString()); + currentStep = step; } }); From 87f03361fd2e069266ec374905271712e1ab8b41 Mon Sep 17 00:00:00 2001 From: jancorvus Date: Tue, 24 May 2022 16:47:32 +0300 Subject: [PATCH 2/3] refactor(step): if an argument of a step is an object and the object has a secret(property), it will be obfuscated with '*****' --- lib/step.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/step.js b/lib/step.js index 490a00e35..35b356756 100644 --- a/lib/step.js +++ b/lib/step.js @@ -172,7 +172,11 @@ class Step { } else if (arg.toString && arg.toString() !== '[object Object]') { return arg.toString(); } else if (typeof arg === 'object') { - return JSON.stringify(arg); + return JSON.stringify( + Object.fromEntries( + Object.entries(arg).map(([key, value]) => [key, value instanceof Secret ? '*****' : value]) + ) + ); } return arg; }).join(', '); From 46c567696450a995397ad877436dcf015ccb63ce Mon Sep 17 00:00:00 2001 From: jancorvus Date: Fri, 27 May 2022 16:55:05 +0300 Subject: [PATCH 3/3] refactor(step): Updated the documentation about the usage of secret() on a property value of an object; fixed lint errors --- docs/basics.md | 2 ++ lib/step.js | 4 ++-- test/acceptance/codecept.Playwright.js | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/basics.md b/docs/basics.md index 9fca12d4e..d67847006 100644 --- a/docs/basics.md +++ b/docs/basics.md @@ -210,6 +210,8 @@ To fill in sensitive data use the `secret` function, it won't expose actual valu ```js I.fillField('password', secret('123456')); +// you can also mask a property value in an object as an argument +I.doMyCustomLogIn({ login: 'Jan', password: secret('12345') }); ``` ### Assertions diff --git a/lib/step.js b/lib/step.js index 35b356756..a2f42bb63 100644 --- a/lib/step.js +++ b/lib/step.js @@ -174,8 +174,8 @@ class Step { } else if (typeof arg === 'object') { return JSON.stringify( Object.fromEntries( - Object.entries(arg).map(([key, value]) => [key, value instanceof Secret ? '*****' : value]) - ) + Object.entries(arg).map(([key, value]) => [key, value instanceof Secret ? '*****' : value]), + ), ); } return arg; diff --git a/test/acceptance/codecept.Playwright.js b/test/acceptance/codecept.Playwright.js index 7cb3f0889..ce8747760 100644 --- a/test/acceptance/codecept.Playwright.js +++ b/test/acceptance/codecept.Playwright.js @@ -12,9 +12,9 @@ module.exports.config = { restart: process.env.BROWSER_RESTART || false, browser: process.env.BROWSER || 'chromium', ignoreHTTPSErrors: true, - webkit: { - ignoreHTTPSErrors: true, - } + webkit: { + ignoreHTTPSErrors: true, + }, }, JSONResponse: { requestHelper: 'Playwright',