# cypress-test-helper

> Cypress test helper

Latest version **1.0.10** (published 2023-12-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install cypress-test-helper
pnpm add cypress-test-helper
yarn add cypress-test-helper
bun add cypress-test-helper
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2023-12-04 |
| First published | 2023-11-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 27.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | naveen.kanak |
| Maintainers | naveenkanak2023 |
| Keywords | test |

## Links

- npm: https://www.npmjs.com/package/cypress-test-helper
- npm.io page: https://npm.io/package/cypress-test-helper

## Dependencies (2)

- [cypress](https://npm.io/package/cypress.md) ^13.5.1
- [typescript](https://npm.io/package/typescript.md) ^5.2.2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.10 (latest) — 2023-12-04
- 1.0.9 — 2023-12-04
- 1.0.8 — 2023-12-04
- 1.0.7 — 2023-12-03
- 1.0.6 — 2023-12-03
- 1.0.5 — 2023-12-03
- 1.0.4 — 2023-11-21
- 1.0.2 — 2023-11-21
- 1.0.1 — 2023-11-21
- 1.0.0 — 2023-11-21

## README

## Benefits of Using cypress-test-helper library

- **Enhanced Readability:** Custom commands improve test code readability by replacing repetitive code with concise and self-explanatory functions.

- **Reduced Code Duplication:** Custom commands eliminate the need to duplicate code in different test scenarios, reducing redundancy and improving code maintainability.

- **Encapsulated Complex Logic:** Custom commands allow complex test logic to be encapsulated, making it easier to understand and reuse throughout the test suite.

- **Simplified Cypress Tests:** These utility functions simplify Cypress tests by providing concise and reusable methods for locating and interacting with DOM elements.

## Available Custom Commands

Custom commands available in this library:

### shouldExist

- **Description:** Asserts that an element exists in the DOM.

- **Example:**

```typescript
cy.get("selector").shouldExist();
```

### shouldBeVisible

- **Description:** Asserts that an element is visible in the viewport.

- **Example:**

```typescript
cy.get("selector").shouldBeVisible();
```

### shouldBeHidden

- **Description:** Asserts that an element is hidden in the viewport.

- **Example:**

```typescript
cy.get("selector").shouldBeHidden();
```

### shouldBeEnabled

- **Description:** Asserts that an element is enabled in the viewport.

- **Example:**

```typescript
cy.get("selector").shouldBeEnabled();
```

### shouldBeDisabled

- **Description:** Asserts that an element is disabled in the viewport.

- **Example:**

```typescript
cy.get("selector").shouldBeDisabled();
```

### shouldBeChecked

- **Description:** Asserts that an element is checked in the viewport.

- **Example:**

```typescript
cy.get("selector").shouldBeChecked();
```

### shouldBeUnChecked

- **Description:** Asserts that an element is unchecked in the viewport.

- **Example:**

```typescript
cy.get("selector").shouldBeUnChecked();
```

### shouldHaveText

- **Description:** Asserts that an element contains the specified text.

- **Example:**

```typescript
cy.get("#elementWithText").shouldHaveText("Expected Text");
```

### shouldHaveHref

- **Description:** Asserts that an element has the specified href attribute.

- **Example:**

```typescript
cy.get("#link").shouldHaveHref("/about");
```

### verifyTextDisplayed

- **Description:** Asserts that an element is visible and contains the specified text.

- **Example:**

```typescript
cy.verifyTextDisplayed("Welcome to Cypress Custom Commands!");
```

### verifyTextboxValue

- **Description:** Asserts that a textbox has the specified value.

- **Example:**

```typescript
cy.verifyTextboxValue("Default Text");
```

### verifyElementDoesNotExist

- **Description:** Asserts that an element does not exist in the DOM.

- **Example:**

```typescript
cy.verifyElementDoesNotExist("#nonExistentElement");
```

### shouldHavePlaceHolder

- **Description:** Asserts that an input element has the specified placeholder text.

- **Example:**

```typescript
cy.get("#inputWithPlaceholder").shouldHavePlaceHolder("Enter your text");
```

## Cypress Utility Functions

Documentation for a set of utility functions that can be used in Cypress tests to locate and interact with DOM elements:

**textboxByLabel:**

- **Description:** Locates a textbox by its associated label text.
- **Usage:**

```typescript
cy.textboxByLabel("Email Address").type("johndoe@example.com");
```

**textboxByRoleName:**

- **Description:** Locates a textbox by its aria-label attribute.
- **Usage:**

```typescript
cy.textboxByRoleName("Search Field").type("Search Query");
```

**dropdownByRoleName:**

- **Description:** Locates a dropdown by its aria-label attribute.
- **Usage:**

```typescript
cy.dropdownByRoleName("Select Category").select("Electronics");
```

**linkByText:**

- **Description:** Locates a link by its visible text content.
- **Usage:**

```typescript
cy.linkByText("Learn More").click();
```

**buttonByText:**

- **Description:** Locates a button by its visible text content.
- **Usage:**

```typescript
cy.buttonByText("Submit").click();
```

**buttonByRoleName:**

- **Description:** Locates a button by its aria-label attribute.
- **Usage:**

```typescript
cy.buttonByRoleName("Add to Cart").click();
```

**byLabel:**

- **Description:** Locates an element by its associated label text.
- **Usage:**

```typescript
cy.byLabel("Username").type("johndoe");
```

**byText:**

- **Description:** Locates an element by its visible text content.
- **Usage:**

```typescript
cy.byText("Welcome to the Dashboard").should("be.visible");
```

**byDataCy:**

- **Description:** Locates an element by its data-cy attribute.
- **Usage:**

```typescript
cy.byDataCy("login-button").click();
```

---
_Source: https://npm.io/package/cypress-test-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
