Skip to content

Commit

Permalink
Merge pull request #821 from gemini-testing/HERMIONE-1308.disable_iso…
Browse files Browse the repository at this point in the history
…lation

fix: ability to disable tests isolation
  • Loading branch information
DudaGod authored Dec 27, 2023
2 parents 5bbed80 + 51b87fd commit a577d21
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/config/browser-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
}),
});
Expand Down
2 changes: 1 addition & 1 deletion src/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
40 changes: 40 additions & 0 deletions test/src/config/browser-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit a577d21

Please sign in to comment.