Test: Added .env toggles for local testing and screenshot directory#487
Test: Added .env toggles for local testing and screenshot directory#487MaksRomanchuk wants to merge 4 commits intoAPIs-guru:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces environment-based configuration for test execution and refactors the page object model for better code organization. It enables developers to run tests locally without Docker for easier debugging while maintaining the existing Docker-based CI testing approach. The PR also adds optional screenshot saving functionality for local test development.
Changes:
- Added
.envfile support withTEST_ENVtoggle (docker/local) and optionalSNAPSHOT_SAVE_DIRconfiguration - Refactored monolithic
PageObjectModel.tsinto a modular directory structure undertests/pageObjectModel/ - Implemented
compareWithSnapshot()method to conditionally skip snapshot comparisons in local mode
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| .env.example | Provides template for environment configuration with TEST_ENV and SNAPSHOT_SAVE_DIR variables |
| .gitignore | Adds .env and /playwright-screenshots to ignored files |
| package.json | Adds dotenv ^17.3.1 as dev dependency |
| package-lock.json | Updates lock file with dotenv dependency |
| playwright.config.ts | Conditionally configures projects and web servers based on TEST_ENV; loads .env file |
| tests/PageObjectModel.ts | Deleted - split into modular structure |
| tests/pageObjectModel/index.ts | New entry point that loads dotenv and exports gotoVoyagerPage and SchemaPresets |
| tests/pageObjectModel/goToVoyagerPage.ts | Extracted function for navigating to Voyager page with error handling |
| tests/pageObjectModel/PlaywrightVoyagerPage.ts | Page object with new compareWithSnapshot method for conditional snapshot testing |
| tests/pageObjectModel/schema/changeDialog.ts | Schema dialog page object component |
| tests/pageObjectModel/schema/index.ts | Barrel export for schema-related page objects |
| tests/pageObjectModel/schema/presets.ts | Schema preset constants |
| tests/pageObjectModel/schema/tabs.ts | Tab components for schema dialog |
| tests/demo.spec.ts | Updated imports and replaced toHaveScreenshot with compareWithSnapshot; added explicit waits for UI elements |
| tests/express.spec.ts | Updated import path to new pageObjectModel structure |
| tests/webpack.spec.ts | Updated import path to new pageObjectModel structure |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 16 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| this.displayButton = this.dialog.getByRole('button', { name: 'Display' }); | ||
| this.cancelButton = this.dialog.getByRole('button', { name: 'Cancel' }); | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
у тебе едітор не додає нормально трейлінг нову лінію
додай будьласка в файли
| @@ -0,0 +1,3 @@ | |||
| export * from './changeDialog.ts'; | |||
| export * from './presets.ts'; | |||
| export * from './tabs.ts'; No newline at end of file | |||
There was a problem hiding this comment.
я індекс файли майже ніколи не роблю хіба якщо це частина публічно АПІ тоді ок
| 'Yelp', | ||
| 'Shopify Storefront', | ||
| 'GitHub', | ||
| ] as const; No newline at end of file |
There was a problem hiding this comment.
занадто дрібні експорти
я для таких штук не створюю окремі файли
| use: { baseURL: 'http://serve-express-example:9090' }, | ||
| }, | ||
| ], | ||
| projects: isLocalTesting |
There was a problem hiding this comment.
локал тестінг не повинно змінювати список проектів тільки
варіант де браузер працює
локально чи ні
| wsEndpoint: 'ws://127.0.0.1:3000/', | ||
| exposeNetwork: '<loopback>', | ||
| }, | ||
| }), |
| ? [ | ||
| { | ||
| name: 'npm run serve', | ||
| command: 'npm run serve', |
There was a problem hiding this comment.
щоб не дублювати значення може зроби змінні в кінці файлу
тоді і тексту менше буде і зрозуміти легше
| }); | ||
|
|
||
| this.changeSchemaDialog = new PlaywrightChangeSchemaDialog(page); | ||
| this.snapshotSaveDir = process.env['SNAPSHOT_SAVE_DIR']; |
There was a problem hiding this comment.
дуже складно зрозуміти який код в мене вже був а який додався новий
перенеси будьласка назад в один файл тільки новий код виділявся
розділити мабуть варто але окремою зміною + я б не виносив зовсім маленькі константи і класи в окремі файли
.env.example
Outdated
| TEST_ENV=docker | ||
|
|
||
| # Directory path to save screenshots of tests. No screenshots will be saved if the variable is not set. | ||
| SNAPSHOT_SAVE_DIR=./playwright-screenshots No newline at end of file |
There was a problem hiding this comment.
навіщо то робити опцією
я б просто зробив би папку playwright-local-screenshots і додав би в гітігнор і не робив би опцію
There was a problem hiding this comment.
і доречі, і я б тоді дот енв не робив.
бо навіть локально тести треба запускати в докері бо це правильніше
а запустити через локальний браузер то треба тільки для дебага і для інших не типиових випадків
а дот енв буде кожного разу загружатись і вийде що локально ніколи не запускається + можна легко забути поміняти в файлі
то менше очевидно ніж в шелі додати TEST_ENV="local"
можна ще спростити і зробити NO_DOCKER=1 (де просто сам факт зміної враховується а значення не важливе)
List of changes:
.envfile in non-production environments and added.env.example.docker(default, execute tests inside docker container)local(run tests locally, ignoring snapshot comparison)