Skip to content

Instantly share code, notes, and snippets.

View filiphric's full-sized avatar
⏯️
Working at Replay.io

Filip Hric filiphric

⏯️
Working at Replay.io
View GitHub Profile
@filiphric
filiphric / mailosaur.js
Last active August 11, 2022 10:48
Cypress request to mailosaur API
const userEmail = 'email.abcdefg@mailosaur.io'
describe('Reset password flow', () => {
it('Should receive an email and use reset password link', () => {
// trigger reset password for user
// this command is equal to clicking „I forgot my password“ link and entering user email
cy
.userPasswordReset(userEmail)
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: ''
beforeEach( function() {
window.logCalls = 1;
window.testFlow = [];
});
Cypress.Commands.overwrite('log', (originalFn, message) => {
Cypress.log({
displayName: `--- ${window.logCalls}. ${message} ---`,
name: `--- ${window.logCalls}. ${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 / 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
}
})
})