From f55fd3421a140e5fcac15a3477ffdb12d671e32a Mon Sep 17 00:00:00 2001 From: Sharode <60081532+Sharode@users.noreply.github.com> Date: Mon, 30 Mar 2020 14:10:08 -0400 Subject: [PATCH 1/5] fixed typo in basic within section readme (#2294) --- docs/basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basics.md b/docs/basics.md index d3cb25dca..9e02721fe 100644 --- a/docs/basics.md +++ b/docs/basics.md @@ -622,7 +622,7 @@ within('.js-signup-form', () => { I.see('There were problems creating your account.'); ``` -> ⚠ `within` can cause problems when used incorrectly. If you see a weired behavior of a test try to refactor it to not use `within`. It is recommended to keep within for simplest cases when possible. +> ⚠ `within` can cause problems when used incorrectly. If you see a weird behavior of a test try to refactor it to not use `within`. It is recommended to keep within for simplest cases when possible. `within` can also work with IFrames. A special `frame` locator is required to locate the iframe and get into its context. From 2958b92643e8384614ea3de2cce084a6f732209e Mon Sep 17 00:00:00 2001 From: Paul Vincent Beigang Date: Fri, 27 Mar 2020 22:24:58 +0100 Subject: [PATCH 2/5] Store --profile in process.env.profile instead of process.profile to make it available in workers. --- docs/configuration.md | 4 ++-- examples/codecept.conf.example.js | 4 ++-- lib/command/interactive.js | 2 +- lib/command/run-multiple.js | 2 +- lib/command/run-rerun.js | 2 +- lib/command/run-workers.js | 2 +- lib/command/run.js | 2 +- test/data/sandbox/config.js | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index f8edcaa58..17940cafe 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -118,7 +118,7 @@ exports.config = { ## Profile -Using values from `process.profile` you can change the config dynamically. +Using `process.env.profile` you can change the config dynamically. It provides value of `--profile` option passed to runner. Use its value to change config value on the fly. @@ -134,7 +134,7 @@ exports.config = { WebDriver: { url: 'http://localhost:3000', // load value from `profile` - browser: process.profile || 'firefox' + browser: process.env.profile || 'firefox' } } diff --git a/examples/codecept.conf.example.js b/examples/codecept.conf.example.js index 8f5d63510..da0bc889d 100644 --- a/examples/codecept.conf.example.js +++ b/examples/codecept.conf.example.js @@ -1,6 +1,6 @@ console.log('Use JS config file'); -console.log(process.profile); +console.log(process.env.profile); exports.config = { tests: './*_test.js', @@ -9,7 +9,7 @@ exports.config = { helpers: { WebDriverIO: { url: 'http://localhost', - browser: process.profile || 'firefox', + browser: process.env.profile || 'firefox', restart: true, }, }, diff --git a/lib/command/interactive.js b/lib/command/interactive.js index f49542487..53fbdb3c6 100644 --- a/lib/command/interactive.js +++ b/lib/command/interactive.js @@ -6,7 +6,7 @@ const event = require('../event'); const output = require('../output'); module.exports = function (path, options) { - process.profile = options.profile; + process.env.profile = options.profile; const testsPath = getTestRoot(path); const config = getConfig(testsPath); diff --git a/lib/command/run-multiple.js b/lib/command/run-multiple.js index 8bf77b4e2..9265ae045 100644 --- a/lib/command/run-multiple.js +++ b/lib/command/run-multiple.js @@ -29,7 +29,7 @@ let processesDone; module.exports = function (selectedRuns, options) { // registering options globally to use in config - process.profile = options.profile; + process.env.profile = options.profile; const configFile = options.config; let codecept; diff --git a/lib/command/run-rerun.js b/lib/command/run-rerun.js index eee1f2b65..2faa0a7d2 100644 --- a/lib/command/run-rerun.js +++ b/lib/command/run-rerun.js @@ -7,7 +7,7 @@ const Codecept = require('../rerun'); module.exports = function (test, options) { // registering options globally to use in config - process.profile = options.profile; + process.env.profile = options.profile; const configFile = options.config; let codecept; diff --git a/lib/command/run-workers.js b/lib/command/run-workers.js index cb8361134..1131c14f7 100644 --- a/lib/command/run-workers.js +++ b/lib/command/run-workers.js @@ -32,7 +32,7 @@ module.exports = function (workers, options) { 'Required minimum Node version of 11.7.0 to work with "run-workers"', ); - process.profile = options.profile; + process.env.profile = options.profile; const { Worker } = require('worker_threads'); diff --git a/lib/command/run.js b/lib/command/run.js index f9a65ee2f..d03248566 100644 --- a/lib/command/run.js +++ b/lib/command/run.js @@ -10,7 +10,7 @@ const Codecept = require('../codecept'); module.exports = function (test, options) { // registering options globally to use in config - process.profile = options.profile; + process.env.profile = options.profile; const configFile = options.config; let codecept; diff --git a/test/data/sandbox/config.js b/test/data/sandbox/config.js index 460dea48c..e11369349 100644 --- a/test/data/sandbox/config.js +++ b/test/data/sandbox/config.js @@ -1,4 +1,4 @@ -const profile = process.profile; +const profile = process.env.profile; exports.config = { tests: './*_test.js', From 6d19770d956aa4ea71512ccb7aad99b108159a27 Mon Sep 17 00:00:00 2001 From: Paul Vincent Beigang Date: Tue, 31 Mar 2020 12:26:33 +0200 Subject: [PATCH 3/5] Backward compatibility for using in process.profile. --- lib/command/interactive.js | 2 ++ lib/command/run-rerun.js | 3 ++- lib/command/run.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/command/interactive.js b/lib/command/interactive.js index 53fbdb3c6..a19245c63 100644 --- a/lib/command/interactive.js +++ b/lib/command/interactive.js @@ -6,6 +6,8 @@ const event = require('../event'); const output = require('../output'); module.exports = function (path, options) { + // Backward compatibility for --profile + process.profile = options.profile; process.env.profile = options.profile; const testsPath = getTestRoot(path); diff --git a/lib/command/run-rerun.js b/lib/command/run-rerun.js index 2faa0a7d2..46e56c743 100644 --- a/lib/command/run-rerun.js +++ b/lib/command/run-rerun.js @@ -7,7 +7,8 @@ const Codecept = require('../rerun'); module.exports = function (test, options) { // registering options globally to use in config - process.env.profile = options.profile; + // Backward compatibility for --profile + process.profile = options.profile; const configFile = options.config; let codecept; diff --git a/lib/command/run.js b/lib/command/run.js index d03248566..33e56be97 100644 --- a/lib/command/run.js +++ b/lib/command/run.js @@ -10,6 +10,8 @@ const Codecept = require('../codecept'); module.exports = function (test, options) { // registering options globally to use in config + // Backward compatibility for --profile + process.profile = options.profile; process.env.profile = options.profile; const configFile = options.config; let codecept; From a535f99754276ec324d892e730c61792f8c1b1b0 Mon Sep 17 00:00:00 2001 From: Paul Vincent Beigang Date: Tue, 31 Mar 2020 13:43:58 +0200 Subject: [PATCH 4/5] Add fallback in test config. --- test/data/sandbox/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/data/sandbox/config.js b/test/data/sandbox/config.js index e11369349..7244343c9 100644 --- a/test/data/sandbox/config.js +++ b/test/data/sandbox/config.js @@ -1,4 +1,4 @@ -const profile = process.env.profile; +const profile = process.env.profile || process.profile; exports.config = { tests: './*_test.js', From b5ee660b6b24ac6c4992b32304f9f0fd625a3a9a Mon Sep 17 00:00:00 2001 From: Paul Vincent Beigang Date: Tue, 31 Mar 2020 19:04:51 +0200 Subject: [PATCH 5/5] Store --profile in process.env.profile also for run-rerun command. --- lib/command/run-rerun.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/command/run-rerun.js b/lib/command/run-rerun.js index 46e56c743..3b5e28df0 100644 --- a/lib/command/run-rerun.js +++ b/lib/command/run-rerun.js @@ -9,6 +9,7 @@ module.exports = function (test, options) { // registering options globally to use in config // Backward compatibility for --profile process.profile = options.profile; + process.env.profile = options.profile; const configFile = options.config; let codecept;