Skip to content

Commit

Permalink
Merge pull request #125 from ShellyDCMS/add-should-not-have-attr
Browse files Browse the repository at this point in the history
Add should not have attr
  • Loading branch information
ShellyDCMS authored Aug 21, 2024
2 parents 4232a3f + ae2d60d commit 609969a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 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.29",
"version": "2.1.30",
"author": "Shelly Goldblit",
"private": false,
"license": "MIT",
Expand Down
20 changes: 14 additions & 6 deletions src/assertable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ 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 does not has the given attribute, using `.attr()`.
* Optionally, assert a particular value as well. The return value is available for chaining.
* @example
* ```ts
* then(get.elementByTestId("selector")).shouldNotHaveAttribute("test")
* ```
*/
public shouldNotHaveAttribute = (attribute: string, expectedValue: string) =>
this.chainable.should("not.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.
Expand Down Expand Up @@ -491,16 +502,13 @@ export class Assertable<T> {
*
* class Driver {
* public given = {
* .
* .
* // methods for setting test pre-conditions
* };
* public when = {
* .
* .
* // methods for test "actions", such as click, darg & drop, etc.
* };
* public get = {
* .
* .
* // getter, for exploring the outcome, such as getting a text color a span
* };
* public then = (chainable: Cypress.Chainable<any>) => new MyAssertable(chainable);
* }
Expand Down

0 comments on commit 609969a

Please sign in to comment.