diff --git a/docs/helpers/FileSystem.md b/docs/helpers/FileSystem.md index c7dfa0df1..0af9843db 100644 --- a/docs/helpers/FileSystem.md +++ b/docs/helpers/FileSystem.md @@ -140,7 +140,7 @@ I.waitForFile('largeFilesName.txt', 10); // wait 10 seconds for file ### writeToFile -Writes test to file +Writes text to file #### Parameters diff --git a/lib/command/info.js b/lib/command/info.js index 48e4e7402..933a469a6 100644 --- a/lib/command/info.js +++ b/lib/command/info.js @@ -37,3 +37,27 @@ module.exports = async function (path) { output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues'); output.print('***************************************'); }; + +module.exports.getMachineInfo = async () => { + const info = { + nodeInfo: await envinfo.helpers.getNodeInfo(), + osInfo: await envinfo.helpers.getOSInfo(), + cpuInfo: await envinfo.helpers.getCPUInfo(), + chromeInfo: await envinfo.helpers.getChromeInfo(), + edgeInfo: await envinfo.helpers.getEdgeInfo(), + firefoxInfo: await envinfo.helpers.getFirefoxInfo(), + safariInfo: await envinfo.helpers.getSafariInfo(), + }; + + output.print('***************************************'); + for (const [key, value] of Object.entries(info)) { + if (Array.isArray(value)) { + output.print(`${key}: ${value[1]}`); + } else { + output.print(`${key}: ${JSON.stringify(value, null, ' ')}`); + } + } + output.print('If you need more detailed info, just run this: npx codeceptjs info'); + output.print('***************************************'); + return info; +}; diff --git a/lib/command/run-workers.js b/lib/command/run-workers.js index c83b102f8..20fa44f51 100644 --- a/lib/command/run-workers.js +++ b/lib/command/run-workers.js @@ -41,8 +41,8 @@ module.exports = async function (workerCount, selectedRuns, options) { try { if (options.verbose) { global.debugMode = true; - const getInfo = require('./info'); - await getInfo(); + const { getMachineInfo } = require('./info'); + await getMachineInfo(); } await workers.bootstrapAll(); await workers.run(); diff --git a/lib/command/run.js b/lib/command/run.js index 1c39a895b..f494e6a20 100644 --- a/lib/command/run.js +++ b/lib/command/run.js @@ -31,8 +31,8 @@ module.exports = async function (test, options) { if (options.verbose) { global.debugMode = true; - const getInfo = require('./info'); - await getInfo(); + const { getMachineInfo } = require('./info'); + await getMachineInfo(); } await codecept.run(); diff --git a/lib/data/context.js b/lib/data/context.js index 8b26b76fb..4d6d21bdf 100644 --- a/lib/data/context.js +++ b/lib/data/context.js @@ -23,6 +23,7 @@ module.exports = function (context) { .inject({ current: dataRow.data })); } }); + maskSecretInTitle(scenarios); return new DataScenarioConfig(scenarios); }, only: { @@ -42,6 +43,7 @@ module.exports = function (context) { .inject({ current: dataRow.data })); } }); + maskSecretInTitle(scenarios); return new DataScenarioConfig(scenarios); }, }, @@ -71,12 +73,6 @@ function replaceTitle(title, dataRow) { // it should be printed if (Object.prototype.toString.call(dataRow.data) === (Object()).toString() && dataRow.data.toString() !== (Object()).toString()) { - Object.entries(dataRow.data).forEach(entry => { - const [key, value] = entry; - if (value instanceof Secret) { - dataRow.data[key] = value.getMasked(); - } - }); return `${title} | ${dataRow.data}`; } @@ -119,3 +115,15 @@ function detectDataType(dataTable) { throw new Error('Invalid data type. Data accepts either: DataTable || generator || Array || function'); } + +function maskSecretInTitle(scenarios) { + scenarios.forEach(scenario => { + const res = []; + + scenario.test.title.split(',').forEach(item => { + res.push(item.replace(/{"_secret":"(.*)"}/, '"*****"')); + }); + + scenario.test.title = res.join(','); + }); +} diff --git a/lib/helper/FileSystem.js b/lib/helper/FileSystem.js index a7d3efb62..830936c7d 100644 --- a/lib/helper/FileSystem.js +++ b/lib/helper/FileSystem.js @@ -52,7 +52,7 @@ class FileSystem extends Helper { } /** - * Writes test to file + * Writes text to file * @param {string} name * @param {string} text */ diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 9b294e69c..d950b2a5a 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -3259,7 +3259,7 @@ async function findElement(matcher, locator) { if (locator.react) return findReact(matcher, locator); locator = new Locator(locator, 'css'); - return matcher.locator(buildLocatorString(locator)); + return matcher.locator(buildLocatorString(locator)).first(); } async function getVisibleElements(elements) { diff --git a/lib/session.js b/lib/session.js index c55431f7e..a037f0e21 100644 --- a/lib/session.js +++ b/lib/session.js @@ -19,7 +19,7 @@ const savedSessions = {}; * @param {CodeceptJS.LocatorOrString} sessionName * @param {Function | Object} config * @param {Function} [fn] - * @return {Promise<*> | undefined} + * @return {any} */ function session(sessionName, config, fn) { if (typeof config === 'function') { diff --git a/test/runner/interface_test.js b/test/runner/interface_test.js index 28652cb84..efbfcd37a 100644 --- a/test/runner/interface_test.js +++ b/test/runner/interface_test.js @@ -37,8 +37,7 @@ describe('CodeceptJS Interface', () => { it('should not propagate retries to non retried steps', (done) => { exec(`${config_run_config('codecept.retry.json')} --grep @test2 --verbose`, (err, stdout) => { expect(stdout).toContain('Retry'); // feature - expect(stdout).toContain('Retries: 5'); // test name - expect(err).toBeFalsy(); + expect(stdout).toContain('Retries: 1'); // test name done(); }); }); diff --git a/test/unit/helper/FileSystem_test.js b/test/unit/helper/FileSystem_test.js index 912d5c027..6c2ead30e 100644 --- a/test/unit/helper/FileSystem_test.js +++ b/test/unit/helper/FileSystem_test.js @@ -43,4 +43,12 @@ describe('FileSystem', () => { for FileSystem helper test`); }); + + it('should write text to file', () => { + const outputFilePath = 'data/output/fs_output.txt'; + const text = '123'; + fs.writeToFile(outputFilePath, text); + fs.seeFile(outputFilePath); + fs.seeInThisFile(text); + }); }); diff --git a/translations/fr-FR.js b/translations/fr-FR.js index 8e6804249..d9042a1ad 100644 --- a/translations/fr-FR.js +++ b/translations/fr-FR.js @@ -12,11 +12,15 @@ module.exports = { amOutsideAngularApp: 'suisALExtérieurDeLApplicationAngular', amInsideAngularApp: 'suisALIntérieurDeLApplicationAngular', waitForElement: 'attendsLElément', - waitForClickable: 'attends', + waitForClickable: 'attendsDeCliquer', waitForVisible: 'attendsPourVoir', + waitForEnabled: 'attendsLActivationDe', + waitForInvisible: 'attendsLInvisibilitéDe', + waitInUrl: 'attendsDansLUrl', waitForText: 'attendsLeTexte', moveTo: 'vaisSur', refresh: 'rafraîchis', + refreshPage: 'rafraîchisLaPage', haveModule: 'ajouteLeModule', resetModule: 'réinitialiseLeModule', amOnPage: 'suisSurLaPage', @@ -59,5 +63,13 @@ module.exports = { grabCookie: 'prendsLeCookie', resizeWindow: 'redimensionneLaFenêtre', wait: 'attends', + clearField: 'effaceLeChamp', + dontSeeElementInDOM: 'neVoisPasDansLeDOM', + moveCursorTo: 'bougeLeCurseurSur', + scrollTo: 'défileVers', + sendGetRequest: 'envoieLaRequêteGet', + sendPutRequest: 'envoieLaRequêtePut', + sendDeleteRequest: 'envoieLaRequêteDelete', + sendPostRequest: 'envoieLaRequêtePost', }, };