Skip to content

Instantly share code, notes, and snippets.

@gusmiguens
gusmiguens / script.js
Last active January 27, 2021 18:04
script
const cypress = require('cypress');
const program = require('commander');
const config = require('./__tests__/ui/support/devices');
const OSconfig = require('./__tests__/ui/support/os');
program
.version('0.1.0')
.option('-d, --device <device>', 'run tests on device: <device>')
.option('-osV, --osVersion <osVersion>', 'adds device OS version')
.option('-r, --record', 'records the run in the Cypress dashboard')
@gusmiguens
gusmiguens / devices.js
Last active November 8, 2020 02:56
devices
module.exports = {
iphoneX: {
viewportWidth: 375,
viewportHeight: 812
},
s10: {
viewportWidth: 360,
viewportHeight: 760
},
default: {
@gusmiguens
gusmiguens / program.js
Last active November 8, 2020 02:47
program
program
.version('0.1.0')
.option('-d, --device <device>', 'run tests on device: <device>')
.option('-osV, --osVersion <osVersion>', 'adds device OS version')
.option('-r, --record', 'records the run in the Cypress dashboard')
.option('-o, --open', 'opens cypress');
@gusmiguens
gusmiguens / os.js
Created November 8, 2020 03:00
osVersions
module.exports = {
iOS: {
'11.1': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Mobile/15B93',
'11.4.1': 'Mozilla / 5.0(iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/ 605.1.15(KHTML, like Gecko) Mobile/ 15G77',
'12.1.4': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57',
'12.2': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1',
'12.3': 'Mozilla / 5.0(iPhone; CPU iPhone OS 12_3 like Mac OS X) AppleWebKit/ 605.1.15(KHTML, like Gecko) Mobile/ 15E148',
'13.0': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) relesys_web_client/1.3.10.0 (RelesysApp/1.3.43; net.relesysapp.nettoenterprise)',
'13.3.1': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Ver
@gusmiguens
gusmiguens / cy-start.js
Last active November 10, 2020 22:28
cy-start
//El link del script completo está debajo en el artículo
//The link to the complete script file is down below the article
program.parse(process.argv);
const device = config[program.device] ? program.device : 'default';
const osType = device.indexOf('iphone') > -1 ? 'iOS' : device === 'default' ? 'default' : 'android';
const osVersion = OSconfig[osType][program.osVersion] ? program.osVersion : 'default';
const userAgent = OSconfig[osType][osVersion];
const cypressOptions = {