@konfidoo/primeng-cypress
v0.6.1
Published
Provides Cypress test helpers for PrimeNG components
Maintainers
Readme
primeng-cypress
A lightweight helper library that provides Cypress test helpers for PrimeNG components (examples: pButton,
pTabs, ...).
This README explains how to run the included component tests locally and how to use this library from another project ( locally during development or as an installed dependency).
Contents
lib/commands- implementation and types for commands such aspButton,pTabscypress/- example Cypress tests and support files that show how to register commands and mount Angular components
Supported components
All commands support a generic set of options: general command options
Stability note: The public command API (command names and option shapes) may still change while the package version is below
1.0.0. Consumers should expect possible breaking changes to commands/options until the project reaches1.0.0. Pin the package version in downstream projects or review changelogs before upgrading.
Not yet supported components
- Any PrimeNG component beyond the helpers listed above (e.g.,
pTabMenu,pAccordionwrappers) is not currently exposed by this library.
Prerequisites
- Node.js (>= 16 recommended)
- primeNG (>= 20 recommended)
- A working Cypress setup
How to use this library in another project
There are multiple ways to consume this helper library from another project:
1) As a published package
Simply install the package from npm:
npm install @konfidoo/primeng-cypress --save-devThen in your cypress/support/commands.ts (or cypress/support/e2e.ts) add:
import {registerPrimeNGCommands} from '@konfidoo/primeng-cypress'
registerPrimeNGCommands()This will register the commands globally so you can use them in your tests.
If the package exports other helpers (for example pButton, pTabs for direct usage), import them
from the package
root:
import {pButton} from '@konfidoo/primeng-cypress'TypeScript / IDE integration (important)
To get full TypeScript support and editor autocompletion for the custom commands (e.g. cy.pButton and .pButton()):
This project exposes the declaration for the Cypress augmentations at
lib/commands/cypress.d.tsand the package root types filelib/index.d.tsreferences it. After installing the package the consumer should havenode_modules/@konfidoo/primeng-cypress/lib/commands/cypress.d.tsavailable.If your editor/TS server does not pick up the augmentation automatically, add the following to the consumer's
tsconfig.jsoninclude(copy/paste):{ "include": [ "cypress/**/*.ts", "node_modules/@konfidoo/primeng-cypress/lib/**/*.d.ts", "...other includes..." ] }Alternatively, add the package lib folder to
typeRoots(less common):{ "compilerOptions": { "typeRoots": [ "node_modules/@types", "node_modules/@konfidoo/primeng-cypress/lib" ] } }After changing
tsconfig.json, restart the TypeScript server in your editor (VS Code: Command Palette → "TypeScript: Restart TS server").
Quick troubleshooting (consumer)
- If you see "Property 'pButton' does not exist on type 'Chainable'":
- Ensure
node_modules/@konfidoo/primeng-cypress/lib/commands/cypress.d.tsexists in the consumer project. - Ensure your
tsconfig.jsonincludes that path (see snippet above). - Restart the TypeScript server.
- Ensure you call
registerPrimeNGCommands()in the Cypress support file so the runtime command exists.
- Ensure
Contributing / Running local checks
- For development and contribution instructions, see
CONTRIBUTING.mdwhich contains build, linking, and local development workflows.
License
MIT License
