Skip to content

Commit

Permalink
Merge pull request #438 from ttaerrim/cypress-regression
Browse files Browse the repository at this point in the history
[Feat] 시각적 회귀 테스트를 위한 cypress 세팅 추가
  • Loading branch information
ttaerrim authored Dec 12, 2023
2 parents b453bc1 + 090e0cf commit 110777e
Show file tree
Hide file tree
Showing 8 changed files with 700 additions and 725 deletions.
4 changes: 4 additions & 0 deletions app/frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ dist-ssr

# env
.env.*

# cypress
cypress/snapshots
cypress/screenshots
6 changes: 4 additions & 2 deletions app/frontend/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { defineConfig } from "cypress";
import { defineConfig } from 'cypress';
import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:5173',
setupNodeEvents(on, config) {
// implement node event listeners here
addMatchImageSnapshotPlugin(on, config);
},
},
});
13 changes: 13 additions & 0 deletions app/frontend/cypress/e2e/snapshot.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('Main Page', () => {
it('should render on desktop', () => {
cy.viewport('macbook-13');
cy.visit('/');
cy.matchImageSnapshot('desktop');
});

it('should render on mobile', () => {
cy.viewport('iphone-xr');
cy.visit('/');
cy.matchImageSnapshot('mobile');
});
});
5 changes: 0 additions & 5 deletions app/frontend/cypress/e2e/spec.cy.ts

This file was deleted.

39 changes: 3 additions & 36 deletions app/frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';

addMatchImageSnapshotCommand();
1 change: 1 addition & 0 deletions app/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@vanilla-extract/vite-plugin": "^3.9.0",
"@vitejs/plugin-react": "^4.0.3",
"cypress": "^13.6.1",
"cypress-image-snapshot": "^4.0.1",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
Expand Down
Loading

0 comments on commit 110777e

Please sign in to comment.