Skip to content

Test: Added .env toggles for local testing and screenshot directory#487

Open
MaksRomanchuk wants to merge 4 commits intoAPIs-guru:mainfrom
MaksRomanchuk:test/env-toggle-and-screenshots
Open

Test: Added .env toggles for local testing and screenshot directory#487
MaksRomanchuk wants to merge 4 commits intoAPIs-guru:mainfrom
MaksRomanchuk:test/env-toggle-and-screenshots

Conversation

@MaksRomanchuk
Copy link

List of changes:

  • Added support for .env file in non-production environments and added .env.example.
  • Added environment variable for switching test execution contexts:
    • docker (default, execute tests inside docker container)
    • local (run tests locally, ignoring snapshot comparison)
  • Added an optional environment variable to save test screenshots locally.
  • Split page object model code for easier navigation.

Copilot AI review requested due to automatic review settings February 23, 2026 18:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .env file support with TEST_ENV toggle (docker/local) and optional SNAPSHOT_SAVE_DIR configuration
  • Refactored monolithic PageObjectModel.ts into a modular directory structure under tests/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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у тебе едітор не додає нормально трейлінг нову лінію
додай будьласка в файли

@@ -0,0 +1,3 @@
export * from './changeDialog.ts';
export * from './presets.ts';
export * from './tabs.ts'; No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я індекс файли майже ніколи не роблю хіба якщо це частина публічно АПІ тоді ок

'Yelp',
'Shopify Storefront',
'GitHub',
] as const; No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

занадто дрібні експорти
я для таких штук не створюю окремі файли

use: { baseURL: 'http://serve-express-example:9090' },
},
],
projects: isLocalTesting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

локал тестінг не повинно змінювати список проектів тільки
варіант де браузер працює
локально чи ні

wsEndpoint: 'ws://127.0.0.1:3000/',
exposeNetwork: '<loopback>',
},
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

оце правильна зміна

? [
{
name: 'npm run serve',
command: 'npm run serve',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

щоб не дублювати значення може зроби змінні в кінці файлу
тоді і тексту менше буде і зрозуміти легше

});

this.changeSchemaDialog = new PlaywrightChangeSchemaDialog(page);
this.snapshotSaveDir = process.env['SNAPSHOT_SAVE_DIR'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дуже складно зрозуміти який код в мене вже був а який додався новий
перенеси будьласка назад в один файл тільки новий код виділявся
розділити мабуть варто але окремою зміною + я б не виносив зовсім маленькі константи і класи в окремі файли

.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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

навіщо то робити опцією
я б просто зробив би папку playwright-local-screenshots і додав би в гітігнор і не робив би опцію

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

і доречі, і я б тоді дот енв не робив.
бо навіть локально тести треба запускати в докері бо це правильніше
а запустити через локальний браузер то треба тільки для дебага і для інших не типиових випадків
а дот енв буде кожного разу загружатись і вийде що локально ніколи не запускається + можна легко забути поміняти в файлі
то менше очевидно ніж в шелі додати TEST_ENV="local"

можна ще спростити і зробити NO_DOCKER=1 (де просто сам факт зміної враховується а значення не важливе)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants