Skip to content

Instantly share code, notes, and snippets.

const puppeteer = require('puppeteer');
module.exports.GoogleSocialLogin = async function GoogleSocialLogin(options = {}) {
try {
validateOptions(options);
const browser = await puppeteer.launch({ headless: !!options.headless, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
const page = await browser.newPage();
const { GoogleSocialLogin } = require('./googleLogin');
module.exports = (on, config) => {
on('task', {
'GoogleSocialLogin': GoogleSocialLogin,
});
};
describe('Logging to Google SSO protected event', () => {
it('Receive token and successfully open app', () => {
const socialLoginOptions = {
username: // google name here
password: // google password here
loginUrl: // your login page (in your app), where you would click on a „login with google“ button, this is url which puppeteer will open
resolveUrl: // the page where you land after you come back from google
headless: // set to tru
@filiphric
filiphric / authorization.js
Last active September 28, 2019 05:23
authorization
cy
.request({
method: 'GET',
url: {{url}},
headers: {
// YWJjZA== is 'abcd' encoded to base64
authorization: 'Basic YWJjZA=='
}
});
beforeEach( function() {
window.logCalls = 1;
});
Cypress.Commands.overwrite('log', (originalFn, message) => {
Cypress.log({
displayName: `--- ${window.logCalls}. ${message} ---`,
name: `--- ${window.logCalls}. ${message} ---`,
message: ''
@filiphric
filiphric / index.js
Created February 1, 2021 23:38
Login page object
const app = new Vue({
// ...
}).$mount('#trello-app');
window.app = app;
@filiphric
filiphric / spec.ts
Last active October 12, 2021 19:32
Using cy.viewport() command to test different resolutions
it('viewport test', () => {
cy.visit('/')
cy.viewport(320, 480)
cy.viewport('iphone-5')
});
@filiphric
filiphric / cypress.json
Created October 12, 2021 20:35
Changing user agent in cypress.json
{
"userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"
}
@filiphric
filiphric / spec.ts
Created October 12, 2021 20:39
Changing user agent in cy.visit() command
it('changing user agent', () => {
cy.visit('/', {
onBeforeLoad: (win) => {
Object.defineProperty(win.navigator, 'userAgent', {
value: 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
});
}
})
})
@filiphric
filiphric / spec.ts
Last active October 12, 2021 20:39
Viewing an app on touch device
it('touch device', () => {
cy.visit('/', {
onBeforeLoad: (win) => {
win.ontouchstart = true
}
})
})