playcore.ts
v1.0.6
Published
Core framework to build Playwright based testing solutions
Downloads
33
Readme
playcore.ts — Playwright helper utilities
Lightweight TypeScript helper library around Playwright to simplify common browser/page/locator actions, assertions and integrations (Allure, DB helpers).
Repo layout
- src/ — main TypeScript helpers and utils
- src/browser/manager.ts — browser launcher (
openBrowser) - src/utils/pageUtils.ts — page lifecycle helpers (
getPage,setPage, navigation helpers) - src/utils/locatorUtils.ts — locator helpers (
getLocator,getFirstLocator, ...) - src/utils/actionUtils.ts — click/fill/scroll utilities (
click,fill, ...) - src/utils/waitUtils.ts — load/wait helpers (
waitForPageToLoad) - src/utils/screenshotsUtil.ts — screenshot helpers (
takeScreenshot,capturePageScreenshot) - src/common/env.ts — environment loader (
getEnv) - dbConfig/ — DB connectivity helpers (SQL Server / MySQL adapters)
- src/browser/manager.ts — browser launcher (
Key symbols:
Configuration and tooling:
- package.json — dependencies and lint hooks
- playwright.config.ts — Playwright test config
- tsconfig.json — TypeScript config
- eslint.config.mjs — lint rules
Getting started
Install dependencies
npm installLoad environment (the repo provides
getEnvto pick.env.<ENV>):- Set ENV, e.g.
export ENV=devthen call the helper in your bootstrap test code: seesrc/common/env.ts
- Set ENV, e.g.
Build (types + compile)
npx tscRun Playwright tests
npx playwright test
Note: repository uses Husky + lint-staged to auto-run ESLint & Prettier on staged .ts files (see package.json).
Usage examples (high level)
- Launch browser: use
openBrowserthen create context/page and callsetPage. - Interact: use
getLocatortogether withclick/fill. - Assertions: helper assertions and screenshots available in
src/utils/assertUtils.tsandtakeScreenshot.
Contributing
- Follow lint rules in eslint.config.mjs.
- Run format/lint: staged hooks run
eslint --fixandprettier --writefor*.tsfiles.
Helpful files
- playwright.config.ts — test runner settings
- tsconfig.json — compiler options
- package.json — scripts & deps
📜 License
This project is licensed under the GNU General Public License v3.0 or later (GPL-3.0-or-later).
This means:
- You are free to use, modify, and distribute this code.
- Any derivative work you distribute must also be licensed under GPLv3.
- You may not privatize this code or its derivatives if you distribute them.
- If you use the code internally (without distribution), you are not required to publish your changes.
See the LICENSE file for full details.
