e0c989755e
- Fix specPattern in cypress.config.ts: change from '*.cy.ts' to '*.spec.ts' to match actual test file naming convention - Fix forbidGeolocation command: use callsFake() instead of rejects() which is not a valid Cypress stub method - Remove redundant localStorage cleanup: keep only afterEach hook, remove beforeEach hook to avoid duplication - Remove unused @cypress/schematic dependency from e2e/package.json - Add comprehensive README.md with E2E testing documentation covering test structure, setup, running tests, custom commands, and best practices
27 lines
621 B
TypeScript
27 lines
621 B
TypeScript
/// <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').callsFake(
|
|
(success, error) => {
|
|
error(new GeolocationPositionError())
|
|
}
|
|
)
|
|
})
|
|
})
|
|
|
|
declare global {
|
|
namespace Cypress {
|
|
interface Chainable {
|
|
getByTestId(id: string, timeout?: number): Chainable<JQuery<HTMLElement>>
|
|
forbidGeolocation(): Chainable<void>
|
|
}
|
|
}
|
|
}
|
|
|
|
export {}
|