Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual solution for web testing workshop 2022 #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions web-testing-2022/.happo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// .happo.js
const { RemoteBrowserTarget } = require('happo.io');

module.exports = {
apiKey: process.env.HAPPO_API_KEY,
apiSecret: process.env.HAPPO_API_SECRET,
project: "web-test-2022",
targets: {
"chrome-1080p": new RemoteBrowserTarget("chrome", {
viewport: "1920x1080",
freezeAnimations: "last-frame",
}),
// all viewports https://viewportsizer.com/devices/
// Samsung Galaxy S10+, S10
"chrome-galaxy-s10": new RemoteBrowserTarget("chrome", {
viewport: "360x740",
freezeAnimations: "last-frame",
}),
// iphone viewports https://yesviz.com/iphones.php
"safari-1080p": new RemoteBrowserTarget("safari", {
viewport: "1920x1080",
freezeAnimations: "last-frame",
// so that safari won't cut off the screenshot at window height
scrollStitch: true,
}),
// iphone 12 pro
"safari-iphone-12-pro": new RemoteBrowserTarget("safari", {
viewport: "390x844",
freezeAnimations: "last-frame",
scrollStitch: true,
}),
"Apple-iPad-Pro-12.9": new RemoteBrowserTarget("safari", {
viewport: "1024x1366",
freezeAnimations: "last-frame",
scrollStitch: true,
}),
"Apple-iPad-Air": new RemoteBrowserTarget("safari", {
viewport: "834x1112",
freezeAnimations: "last-frame",
scrollStitch: true,
}),
"MacBook Pro 13.3": new RemoteBrowserTarget("safari", {
viewport: "1280x800",
freezeAnimations: "last-frame",
scrollStitch: true,
}),
"MacBook Pro 16": new RemoteBrowserTarget("safari", {
viewport: "1536x960",
freezeAnimations: "last-frame",
scrollStitch: true,
}),
// iphone 12 pro
"chrome-650": new RemoteBrowserTarget("chrome", {
viewport: "650x415",
freezeAnimations: "last-frame",
}),
},
};
3 changes: 3 additions & 0 deletions web-testing-2022/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const { defineConfig } = require('cypress');
const happoTask = require('happo-cypress/task');

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
happoTask.register(on);
return config;
},
baseUrl: 'http://localhost:3000',
},
Expand Down
13 changes: 13 additions & 0 deletions web-testing-2022/cypress/e2e/visual.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('home page', () => {
beforeEach(() => {
cy.visit('/');
// need to scroll to handle lazy loading
// since our page is tiny, it's not scrollable
cy.scrollTo('bottom', { duration: 5000, ensureScrollable: false });
cy.scrollTo('top', { duration: 3000, ensureScrollable: false });
});

it('looks good', () => {
cy.get('body').happoScreenshot();
});
});
1 change: 1 addition & 0 deletions web-testing-2022/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'happo-cypress';
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
Expand Down
1 change: 0 additions & 1 deletion web-testing-2022/docs/VISUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ Test by running `npm run test:visual`
- Lazy loading
- Long pages


## 📝Summary

✅Visual e2e testing is a simple and efficient way to ensure visual consistency cross-platform and cross-OS
Expand Down
Loading