Skip to content

Commit

Permalink
Projekt: Testy E2E
Browse files Browse the repository at this point in the history
  • Loading branch information
plumcoding committed Feb 24, 2024
1 parent 1fccc41 commit b724fb4
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
- [x] [Globalny stan aplikacji - Context API](docs/06-context/README.md)
- [x] [TypeScript](docs/07-typescript/README.md)
- [ ] [Testy jednostkowe](./docs/08-testy-jednostkowe/README.md)
- [ ] [Testy E2E](./docs/09-testy-e2e/README.md)
29 changes: 29 additions & 0 deletions docs/09-testy-e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Projekt: Testy E2E

Na potrzeby przeprowadzenia testów w katalogu [`dummy`](../../dummy) stworzona została przykładowa aplikacja, a w
katalogu [`dummy-e2e`](../../dummy-e2e) projekt testów E2E.

Przed przystąpieniem do zadań koniecznie zainstaluj zależności w obu projektach, a następnie uruchom aplikację _Dummy_ (
jest wymagana do przeprowadzenia testów).

Wszelkie ścieżki podane poniżej są relatywne dla katalogu wspomnianego projektu - [`dummy-e2e`](../../dummy-e2e).

---

Aplikację _Dummy_ uruchom z poziomu katalogu [`dummy`](../../dummy) poleceniem `npm run dev`.

Konsolę Cypress możesz otworzyć z poziomu katalogu [`dummy-e2e`](../../dummy-e2e) poleceniem `npm run open`.

Testy E2E możesz też uruchomić z poziomu katalogu [`dummy-e2e`](../../dummy-e2e) poleceniem `npm run e2e`.

---

## Strona logowania

W pliku [`cypress/e2e/sign-in.cy.ts`](../../dummy-e2e/cypress/e2e/sign-in.cy.ts) napisz testy funkcjonalne strony
logowania.

## Profil użytkownika

W pliku [`cypress/e2e/account.cy.ts`](../../dummy-e2e/cypress/e2e/account.cy.ts) napisz testy funkcjonalne strony
profilu użytkownika.
10 changes: 10 additions & 0 deletions dummy-e2e/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const {defineConfig} = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:5173',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
6 changes: 6 additions & 0 deletions dummy-e2e/cypress/e2e/account.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('account page', () => {
it('should contain greeting', () => {
})
it('should log user out', () => {
})
})
14 changes: 14 additions & 0 deletions dummy-e2e/cypress/e2e/sign-in.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe('sign-in page', () => {
it('should be opened by default', () => {
cy.visit('/')
})
it('should show invalid email error', () => {
cy.visit('/sign-in')
})
it('should show invalid password error', () => {
cy.visit('/sign-in')
})
it('should navigate to /account', () => {
cy.visit('/sign-in')
})
})
25 changes: 25 additions & 0 deletions dummy-e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js 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) => { ... })
20 changes: 20 additions & 0 deletions dummy-e2e/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
12 changes: 12 additions & 0 deletions dummy-e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "dummy-e2e",
"version": "1.0.0",
"scripts": {
"open": "cypress open",
"e2e": "cypress run"
},
"devDependencies": {
"cypress": "^13.6.6",
"typescript": "^5.3.3"
}
}
16 changes: 16 additions & 0 deletions dummy-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es2022",
"lib": [
"es2022",
"dom"
],
"types": [
"cypress",
"node"
]
},
"include": [
"**/*.ts"
]
}

0 comments on commit b724fb4

Please sign in to comment.