Skip to content

Commit

Permalink
Merge pull request #96 from ShellyDCMS/add-have-prop
Browse files Browse the repository at this point in the history
Test for Property of a DOM object
  • Loading branch information
DebjaniGh committed May 28, 2024
2 parents ce86525 + 8a1cb9c commit 31e7090
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@shellygo/cypress-test-utils",
"description": "Cypress Test Automation Utilities",
"version": "2.1.6",
"version": "2.1.7",
"author": "Shelly Goldblit",
"private": false,
"license": "MIT",
Expand Down
11 changes: 10 additions & 1 deletion src/assertable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,16 @@ export class Assertable<T> {
*/
public shouldHaveAttribute = (attribute: string, expectedValue: string) =>
this.chainable.should("have.attr", attribute, expectedValue);

/**
* Assert that the first element of the selection has the given attribute, using `.prop()`.
* Optionally, assert a particular value as well. The return value is available for chaining.
* @example
* ```ts
* then(get.elementByTestId("selector")).shouldHaveProperty("test")
* ```
*/
public shouldHaveProp = (property: string, expectedValue: string | boolean) =>
this.chainable.should("have.prop", property, expectedValue);
/**
* Assert that an element has a css property with the given value.
* @example
Expand Down

0 comments on commit 31e7090

Please sign in to comment.