Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expect helper #3923

Merged
merged 5 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/expectHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Expect Helper Tests

on:
push:
branches:
- 3.x
pull_request:
branches:
- '**'

env:
CI: true
# Force terminal colors. @see https://www.npmjs.com/package/colors
FORCE_COLOR: 1

jobs:
build:

runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: npm i --legacy-peer-deps
- name: run unit tests
run: ./node_modules/.bin/mocha test/helper/Expect_test.js --timeout 5000
275 changes: 275 additions & 0 deletions docs/helpers/Expect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
---
permalink: /helpers/Expect
editLink: false
sidebar: auto
title: Expect
---

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## ExpectHelper

This helper allows performing assertions based on Chai.

### Examples

Zero-configuration when paired with other helpers like REST, Playwright:

```js
// inside codecept.conf.js
{
helpers: {
Playwright: {...},
ExpectHelper: {},
}
}
```

## Methods

### expectAbove

#### Parameters

- `targetData` **any**
- `aboveThan` **any** number | Date
- `customErrorMsg` **any**

### expectBelow

#### Parameters

- `targetData` **any**
- `belowThan` **any** number | Date
- `customErrorMsg` **any**

### expectContain

#### Parameters

- `actualValue` **any**
- `expectedValueToContain` **any**
- `customErrorMsg` **any**

### expectDeepEqual

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `customErrorMsg` **any**

### expectDeepEqualExcluding

expects members of two JSON objects are deeply equal excluding some properties

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `fieldsToExclude` **any**
- `customErrorMsg` **any**

### expectDeepIncludeMembers

expects an array to be a superset of another array

#### Parameters

- `superset` **any**
- `set` **any**
- `customErrorMsg` **any**

### expectDeepMembers

expects members of two arrays are deeply equal

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `customErrorMsg` **any**

### expectEmpty

#### Parameters

- `targetData` **any**
- `customErrorMsg` **any**

### expectEndsWith

#### Parameters

- `actualValue` **any**
- `expectedValueToEndWith` **any**
- `customErrorMsg` **any**

### expectEqual

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `customErrorMsg` **any**

### expectEqualIgnoreCase

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `customErrorMsg` **any**

### expectFalse

#### Parameters

- `targetData` **any**
- `customErrorMsg` **any**

### expectHasAProperty

#### Parameters

- `targetData` **any**
- `propertyName` **any**
- `customErrorMsg` **any**

### expectHasProperty

#### Parameters

- `targetData` **any**
- `propertyName` **any**
- `customErrorMsg` **any**

### expectJsonSchema

#### Parameters

- `targetData` **any**
- `jsonSchema` **any**
- `customErrorMsg` **any**

### expectJsonSchemaUsingAJV

#### Parameters

- `targetData` **any**
- `jsonSchema` **any**
- `customErrorMsg` **any**
- `ajvOptions` **any** Pass AJV options

### expectLengthAboveThan

#### Parameters

- `targetData` **any**
- `lengthAboveThan` **any**
- `customErrorMsg` **any**

### expectLengthBelowThan

#### Parameters

- `targetData` **any**
- `lengthBelowThan` **any**
- `customErrorMsg` **any**

### expectLengthOf

#### Parameters

- `targetData` **any**
- `length` **any**
- `customErrorMsg` **any**

### expectMatchesPattern

expects a JSON object matches a provided pattern

#### Parameters

- `actualValue` **any**
- `expectedPattern` **any**
- `customErrorMsg` **any**

### expectMatchRegex

#### Parameters

- `targetData` **any**
- `regex` **any**
- `customErrorMsg` **any**

### expectNotContain

#### Parameters

- `actualValue` **any**
- `expectedValueToNotContain` **any**
- `customErrorMsg` **any**

### expectNotDeepEqual

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `customErrorMsg` **any**

### expectNotEndsWith

#### Parameters

- `actualValue` **any**
- `expectedValueToNotEndWith` **any**
- `customErrorMsg` **any**

### expectNotEqual

#### Parameters

- `actualValue` **any**
- `expectedValue` **any**
- `customErrorMsg` **any**

### expectNotStartsWith

#### Parameters

- `actualValue` **any**
- `expectedValueToNotStartWith` **any**
- `customErrorMsg` **any**

### expectStartsWith

#### Parameters

- `actualValue` **any**
- `expectedValueToStartWith` **any**
- `customErrorMsg` **any**

### expectToBeA

#### Parameters

- `targetData` **any**
- `type` **any**
- `customErrorMsg` **any**

### expectToBeAn

#### Parameters

- `targetData` **any**
- `type` **any**
- `customErrorMsg` **any**

### expectTrue

#### Parameters

- `targetData` **any**
- `customErrorMsg` **any**
4 changes: 3 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class Cli extends Base {
}
currentMetaStep = metaSteps;
output.stepShift = 3 + 2 * shift;
output.step(step);
if (step.helper.constructor.name !== 'ExpectHelper') {
output.step(step);
}
});

event.dispatcher.on(event.step.finished, () => {
Expand Down
Loading