Skip to content

Commit

Permalink
Merge pull request #100 from ShellyDCMS/remove-pipe
Browse files Browse the repository at this point in the history
remove pipe
  • Loading branch information
ShellyDCMS committed Jun 2, 2024
2 parents d2f3988 + efef086 commit 3064bd4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
3 changes: 1 addition & 2 deletions 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.9",
"version": "2.1.10",
"author": "Shelly Goldblit",
"private": false,
"license": "MIT",
Expand Down Expand Up @@ -37,7 +37,6 @@
"@cypress/mount-utils": "^4.0.0",
"@types/chai-subset": "^1.3.3",
"chai-subset": "^1.6.0",
"cypress-pipe": "^2.0.0",
"cypress-real-events": "^1.7.6",
"cypress-wait-if-happens": "^1.3.3",
"cypress-wait-until": "^1.7.2",
Expand Down
22 changes: 11 additions & 11 deletions src/assertable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "cypress-pipe";

/** Assertable wraps Cypress.Chainable so that your tests are as decoupled as possible from Cypress.
* By using the Assertable class, you can use the same assertions in your tests, regardless of the testing framework you use.
* All you need to do if you wish to replace Cypress with another testing framework and keep your tests, is to replace the implementation of the Assertable class.
Expand Down Expand Up @@ -100,9 +98,10 @@ export class Assertable<T> {
* ```
*/
public shouldEndWith = (value: string) =>
this.chainable
.pipe(text => (text as string).slice(-value.length))
.should("equal", value);
this.chainable.then(text => {
const suffix = (text as string).slice(-value.length);
cy.wrap(suffix).should("equal", value);
});

/**
* Asserts that text starts with value
Expand All @@ -112,9 +111,10 @@ export class Assertable<T> {
* ```
*/
public shouldStartWith = (value: string) =>
this.chainable
.pipe(text => (text as string).slice(0, value.length))
.should("equal", value);
this.chainable.then(text => {
const prefix = (text as string).slice(0, value.length);
cy.wrap(prefix).should("equal", value);
});

/**
* Causes all `.equal`, `.include`, `.members`, `.keys`, and `.property` assertions that follow in the chain to use deep equality instead of strict (`===`) equality. See the `deep-eql` project page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql.
Expand Down Expand Up @@ -316,16 +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);
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
8 changes: 1 addition & 7 deletions src/cypress-helper.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CypressHelper, loggable, match } from ".";
import { CypressHelper, match } from ".";
import { then } from "./assertable";

describe("cypress helper tests", () => {
Expand Down Expand Up @@ -362,12 +362,6 @@ describe("cypress helper tests", () => {
then(get.elementsText("header")).shouldStartWith("My First");
});

it("should supply cypress pipe", () => {
then(
get.elementsText("header").pipe(loggable(str => str.toLowerCase()))
).shouldEqual("my first heading");
});

it("should get env variable", () => {
then(get.env("env1")).shouldEqual("value1");
});
Expand Down
1 change: 0 additions & 1 deletion src/cypress-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "cypress-wait-until";
import { StringMatcher } from "cypress/types/net-stubbing";
import type { SinonStub } from "cypress/types/sinon";
import { StubbedInstanceCreator } from "ts-stubber";
export * from "cypress-pipe";

/**
* Sinon matcher for stubs/spy comparison
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1449,11 +1449,6 @@ csstype@^3.0.2:
resolved "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz"
integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==

cypress-pipe@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/cypress-pipe/-/cypress-pipe-2.0.0.tgz"
integrity sha512-KW9s+bz4tFLucH3rBGfjW+Q12n7S4QpUSSyxiGrgPOfoHlbYWzAGB3H26MO0VTojqf9NVvfd5Kt0MH5XMgbfyg==

cypress-real-events@^1.7.6:
version "1.10.3"
resolved "https://registry.npmjs.org/cypress-real-events/-/cypress-real-events-1.10.3.tgz"
Expand Down

0 comments on commit 3064bd4

Please sign in to comment.