diff --git a/README.md b/README.md index 374884ad3..3bc6240ae 100644 --- a/README.md +++ b/README.md @@ -1135,7 +1135,7 @@ Ability to choose different datacenters for run in cloud service. Default value Ability to run headless browser in cloud service. Default value is `null`. #### isolation -Ability to execute tests in isolated clean-state environment ([incognito browser context](https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-createBrowserContext)). It means that `testsPerSession` can be set to `Infinity` in order to speed up tests execution and save browser resources. Currently works only in chrome@93 and higher. Default value is `false`, but `true` for chrome@93 and higher. +Ability to execute tests in isolated clean-state environment ([incognito browser context](https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-createBrowserContext)). It means that `testsPerSession` can be set to `Infinity` in order to speed up tests execution and save browser resources. Currently works only in chrome@93 and higher. Default value is `null`, but `true` for chrome@93 and higher. ### system diff --git a/src/config/browser-options.js b/src/config/browser-options.js index 244c0f670..ceec97242 100644 --- a/src/config/browser-options.js +++ b/src/config/browser-options.js @@ -319,15 +319,15 @@ function buildBrowserOptions(defaultFactory, extra) { defaultValue: defaultFactory("isolation"), parseCli: value => utils.parseBoolean(value, "isolation"), parseEnv: value => utils.parseBoolean(value, "isolation"), - validate: is("boolean", "isolation"), + validate: value => _.isNull(value) || is("boolean", "isolation")(value), map: (value, config, currentNode, meta) => { - if (meta.isSpecified) { + if (meta.isSetByUser || !_.isNull(value)) { return value; } const caps = _.get(currentNode, "desiredCapabilities"); - return caps && isSupportIsolation(caps.browserName, caps.browserVersion) ? true : value; + return caps ? isSupportIsolation(caps.browserName, caps.browserVersion) : value; }, }), }); diff --git a/src/config/defaults.js b/src/config/defaults.js index 400a1d216..325719277 100644 --- a/src/config/defaults.js +++ b/src/config/defaults.js @@ -91,7 +91,7 @@ module.exports = { key: null, region: null, headless: null, - isolation: false, + isolation: null, }; module.exports.configPaths = [".hermione.conf.ts", ".hermione.conf.js"]; diff --git a/test/src/config/browser-options.js b/test/src/config/browser-options.js index 5443da888..92f3ed65d 100644 --- a/test/src/config/browser-options.js +++ b/test/src/config/browser-options.js @@ -1200,6 +1200,46 @@ describe("config browser-options", () => { assert.isFalse(config.browsers.b1.isolation); }); + + describe("should set to 'false' by user even if browser support isolation", () => { + it("in top level config", () => { + const readConfig = { + isolation: false, + browsers: { + b1: mkBrowser_({ + desiredCapabilities: { + browserName: "chrome", + browserVersion: "101.0", + }, + }), + }, + }; + Config.read.returns(readConfig); + + const config = createConfig(); + + assert.isFalse(config.browsers.b1.isolation); + }); + + it("in browser config", () => { + const readConfig = { + browsers: { + b1: mkBrowser_({ + isolation: false, + desiredCapabilities: { + browserName: "chrome", + browserVersion: "101.0", + }, + }), + }, + }; + Config.read.returns(readConfig); + + const config = createConfig(); + + assert.isFalse(config.browsers.b1.isolation); + }); + }); }); describe("saveHistoryMode", () => {