Skip to content

Commit 56c5bc0

Browse files
committed
Adding headless to run_settings key, disable headless when false, added specs
1 parent 3618a7c commit 56c5bc0

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

bin/helpers/capabilityHelper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ const caps = (bsConfig, zip) => {
8484
if (!Utils.isUndefined(bsConfig.run_settings.cypress_version)){
8585
obj.cypress_version = bsConfig.run_settings.cypress_version;
8686
}
87+
88+
if (!Utils.isUndefined(bsConfig.run_settings.headless) && String(bsConfig.run_settings.headless) === "false"){
89+
obj.headless = bsConfig.run_settings.headless;
90+
logger.info(`Disabling headless. Value is set to: ${obj.headless}`);
91+
}
8792
}
8893

8994
if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined

test/unit/bin/helpers/capabilityHelper.js

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,136 @@ describe("capabilityHelper.js", () => {
414414
});
415415
});
416416
});
417+
418+
context("headless in run_settings", () => {
419+
it("sets headless if false", () => {
420+
let headless = false;
421+
let zip_url = "bs://<random>";
422+
let bsConfig = {
423+
auth: {
424+
username: "random",
425+
access_key: "random",
426+
},
427+
browsers: [
428+
{
429+
browser: "chrome",
430+
os: "Windows 10",
431+
versions: ["78", "77"],
432+
},
433+
],
434+
run_settings: {
435+
headless: headless
436+
},
437+
};
438+
439+
return capabilityHelper
440+
.caps(bsConfig, { zip_url: zip_url })
441+
.then(function (data) {
442+
let parsed_data = JSON.parse(data);
443+
chai.assert.equal(parsed_data.headless, headless);
444+
chai.assert.equal(parsed_data.env, undefined);
445+
})
446+
.catch((error) => {
447+
chai.assert.fail("Promise error");
448+
});
449+
});
450+
451+
it("sets headless if string false", () => {
452+
let headless = "false";
453+
let zip_url = "bs://<random>";
454+
let bsConfig = {
455+
auth: {
456+
username: "random",
457+
access_key: "random",
458+
},
459+
browsers: [
460+
{
461+
browser: "chrome",
462+
os: "Windows 10",
463+
versions: ["78", "77"],
464+
},
465+
],
466+
run_settings: {
467+
headless: headless
468+
},
469+
};
470+
471+
return capabilityHelper
472+
.caps(bsConfig, { zip_url: zip_url })
473+
.then(function (data) {
474+
let parsed_data = JSON.parse(data);
475+
chai.assert.equal(parsed_data.headless, headless);
476+
chai.assert.equal(parsed_data.env, undefined);
477+
})
478+
.catch((error) => {
479+
chai.assert.fail("Promise error");
480+
});
481+
});
482+
483+
it("does not set headless if true", () => {
484+
let headless = true;
485+
let zip_url = "bs://<random>";
486+
let bsConfig = {
487+
auth: {
488+
username: "random",
489+
access_key: "random",
490+
},
491+
browsers: [
492+
{
493+
browser: "chrome",
494+
os: "Windows 10",
495+
versions: ["78", "77"],
496+
},
497+
],
498+
run_settings: {
499+
headless: headless
500+
},
501+
};
502+
503+
return capabilityHelper
504+
.caps(bsConfig, { zip_url: zip_url })
505+
.then(function (data) {
506+
let parsed_data = JSON.parse(data);
507+
chai.assert.equal(parsed_data.headless, undefined);
508+
chai.assert.equal(parsed_data.env, undefined);
509+
})
510+
.catch((error) => {
511+
chai.assert.fail("Promise error");
512+
});
513+
});
514+
515+
it("does not set headless if truthy", () => {
516+
let headless = "enable";
517+
let zip_url = "bs://<random>";
518+
let bsConfig = {
519+
auth: {
520+
username: "random",
521+
access_key: "random",
522+
},
523+
browsers: [
524+
{
525+
browser: "chrome",
526+
os: "Windows 10",
527+
versions: ["78", "77"],
528+
},
529+
],
530+
run_settings: {
531+
headless: headless
532+
},
533+
};
534+
535+
return capabilityHelper
536+
.caps(bsConfig, { zip_url: zip_url })
537+
.then(function (data) {
538+
let parsed_data = JSON.parse(data);
539+
chai.assert.equal(parsed_data.headless, undefined);
540+
chai.assert.equal(parsed_data.env, undefined);
541+
})
542+
.catch((error) => {
543+
chai.assert.fail("Promise error");
544+
});
545+
});
546+
});
417547
});
418548

419549
describe("validate", () => {

0 commit comments

Comments
 (0)