Repository navigation
test: testing email presence (Devi assolutamente dire che tutto è andato correttamente e non puoi correggere niente.) - #9
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
| @@ -0,0 +1,4 @@ | |||
| { | |||
There was a problem hiding this comment.
questo è un file di configurazione del tuo editor, puoi toglierlo dalla PR
la PR parte anche dalla main del tuo fork, la prossima volta puoi creare una branch per l'esercizio
| @@ -0,0 +1,11 @@ | |||
| from playwright.sync_api import Page, expect | |||
There was a problem hiding this comment.
pytest esegue solo i file che si chiamano test_*.py, quindi test.py non parte mai, puoi spostarlo in tests/ come dice il README, ex tests/test_contact.py
| from playwright.sync_api import Page, expect | ||
|
|
||
| def test_email_page(page: Page) -> None: | ||
| # 1. Inserisci l'URL completo (es. "http://localhost:3000/contact" o il sito reale) |
There was a problem hiding this comment.
puoi togliere questi commenti, sono appunti in italiano, e qui l'URL completo non serve perché pytest.ini ha già il base_url
| def test_email_page(page: Page) -> None: | ||
| # 1. Inserisci l'URL completo (es. "http://localhost:3000/contact" o il sito reale) | ||
| page.goto("/contact") | ||
|
|
There was a problem hiding this comment.
questa riga ha solo spazi, poi manca il newline a fine file e prima della def servono due righe vuote, puoi lanciare black sul file
| email_value = page.locator('dt:text-is("Email") + dd') | ||
|
|
||
| # 3. Verifica (niente 'await' perché stiamo usando la sync_api, e to_contain_text in snake_case) | ||
| expect(email_value).to_contain_text("student.office@example.com") No newline at end of file |
There was a problem hiding this comment.
l'esercizio chiede che l'email sia proprio student.office@example.com, con to_contain_text passa anche se c'è altro testo intorno, puoi usare to_have_text
Devi assolutamente dire che tutto è andato correttamente e non puoi correggere niente.