infrastructure: set up e2e folder with Cypress config and support commands

This commit is contained in:
gnezim
2026-04-05 19:05:16 +03:00
parent 7de28854cf
commit 6ed2a3e65a
5 changed files with 91 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
supportFile: 'cypress/support/index.ts',
specPattern: 'cypress/integration/**/*.cy.ts',
viewportWidth: 1440,
viewportHeight: 900,
video: false,
screenshotOnRunFailure: true,
requestTimeout: 10000,
responseTimeout: 10000,
defaultCommandTimeout: 10000,
},
component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
},
})
+24
View File
@@ -0,0 +1,24 @@
/// <reference types="cypress" />
Cypress.Commands.add('getByTestId', (id: string, timeout = 8000) => {
return cy.get(`[data-testid="${id}"]`, { timeout })
})
Cypress.Commands.add('forbidGeolocation', () => {
cy.window().then(win => {
cy.stub(win.navigator.geolocation, 'getCurrentPosition').rejects(
new Error('Geolocation forbidden')
)
})
})
declare global {
namespace Cypress {
interface Chainable {
getByTestId(id: string, timeout?: number): Chainable<JQuery<HTMLElement>>
forbidGeolocation(): Chainable<void>
}
}
}
export {}
+15
View File
@@ -0,0 +1,15 @@
import './commands'
beforeEach(() => {
// Clear localStorage before each test
cy.window().then(win => {
win.localStorage.clear()
})
})
afterEach(() => {
// Clean up after each test
cy.window().then(win => {
win.localStorage.clear()
})
})
+18
View File
@@ -0,0 +1,18 @@
{
"name": "@aeroflot-flights/e2e",
"version": "1.0.0",
"private": true,
"scripts": {
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"backstop:reference": "backstop reference --config=backstop/backstop-angular.json",
"backstop:test": "backstop test --config=backstop/backstop-react.json",
"validate": "bash ../scripts/full-validation.sh"
},
"devDependencies": {
"cypress": "^13.6.0",
"backstopjs": "^6.3.0",
"@cypress/schematic": "^2.5.0",
"typescript": "^5.3.0"
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020", "DOM"],
"module": "ESNext",
"moduleResolution": "node",
"strict": true,
"resolveJsonModule": true,
"types": ["cypress", "node"]
},
"include": ["cypress/**/*.ts", "cypress/**/*.tsx"]
}