{"id":24753848,"url":"https://github.com/codeceptjs/expect-helper","last_synced_at":"2026-02-15T06:31:34.480Z","repository":{"id":260481538,"uuid":"881420482","full_name":"codeceptjs/expect-helper","owner":"codeceptjs","description":"Expect helper for I.expect calls","archived":false,"fork":false,"pushed_at":"2025-04-03T05:03:14.000Z","size":273,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-12-18T19:22:39.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeceptjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-31T14:37:41.000Z","updated_at":"2025-04-03T05:03:17.000Z","dependencies_parsed_at":"2024-10-31T15:35:53.756Z","dependency_job_id":"16d17e67-90eb-4c90-852c-dae8f1b938eb","html_url":"https://github.com/codeceptjs/expect-helper","commit_stats":null,"previous_names":["codeceptjs/expect-helper"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/codeceptjs/expect-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fexpect-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fexpect-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fexpect-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fexpect-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeceptjs","download_url":"https://codeload.github.com/codeceptjs/expect-helper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fexpect-helper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29471941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T05:26:30.465Z","status":"ssl_error","status_checked_at":"2026-02-15T05:26:21.858Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T11:36:32.625Z","updated_at":"2026-02-15T06:31:34.458Z","avatar_url":"https://github.com/codeceptjs.png","language":"JavaScript","readme":"# expect-helper\n\nExpect helper for I.expect calls\n\nInstallation:\n\n```sh\nnpm i @codeceptjs/expect-helper --save\n```\n\nEnable it inside codecept conf file:\n\n```js\n// inside codecept.conf.js/ts\n{\n  helpers: {\n    Playwright: {...},\n    Expect: {\n      require: '@codeceptjs/expect-helper'\n    },\n  }\n}\n```\n\n## Usage\n\n### I.expectEqual\n\nAsserts that the actual value is equal to the expected value.\n\n```js\nI.expectEqual(actualValue, expectedValue, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be compared.\n- `expectedValue`: The expected value to compare against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectEqual(5, 5); // Passes\nI.expectEqual('hello', 'hello'); // Passes\nI.expectEqual(5, 10, 'Values are not equal'); // Fails with custom error message\n```\n\n### I.expectNotEqual\n\nAsserts that the actual value is not equal to the expected value.\n\n```js\nI.expectNotEqual(actualValue, expectedValue, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be compared.\n- `expectedValue`: The expected value to compare against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectNotEqual(5, 10); // Passes\nI.expectNotEqual('hello', 'world'); // Passes\nI.expectNotEqual(5, 5, 'Values should not be equal'); // Fails with custom error message\n```\n\n### I.expectDeepEqual\n\nAsserts that the actual value is deeply equal to the expected value.\n\n```js\nI.expectDeepEqual(actualValue, expectedValue, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be compared.\n- `expectedValue`: The expected value to compare against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectDeepEqual({ a: 1 }, { a: 1 }); // Passes\nI.expectDeepEqual([1, 2, 3], [1, 2, 3]); // Passes\nI.expectDeepEqual({ a: 1 }, { a: 2 }, 'Objects are not deeply equal'); // Fails with custom error message\n```\n\n### I.expectNotDeepEqual\n\nAsserts that the actual value is not deeply equal to the expected value.\n\n```js\nI.expectNotDeepEqual(actualValue, expectedValue, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be compared.\n- `expectedValue`: The expected value to compare against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectNotDeepEqual({ a: 1 }, { a: 2 }); // Passes\nI.expectNotDeepEqual([1, 2, 3], [4, 5, 6]); // Passes\nI.expectNotDeepEqual({ a: 1 }, { a: 1 }, 'Objects should not be deeply equal'); // Fails with custom error message\n```\n\n### I.expectContain\n\nAsserts that the actual value contains the expected value.\n\n```js\nI.expectContain(actualValue, expectedValueToContain, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be checked.\n- `expectedValueToContain`: The value expected to be contained within the actual value.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectContain([1, 2, 3], 2); // Passes\nI.expectContain('hello world', 'world'); // Passes\nI.expectContain([1, 2, 3], 4, 'Array does not contain the value'); // Fails with custom error message\n```\n\n### I.expectNotContain\n\nAsserts that the actual value does not contain the expected value.\n\n```js\nI.expectNotContain(actualValue, expectedValueToNotContain, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be checked.\n- `expectedValueToNotContain`: The value expected not to be contained within the actual value.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectNotContain([1, 2, 3], 4); // Passes\nI.expectNotContain('hello world', 'universe'); // Passes\nI.expectNotContain([1, 2, 3], 2, 'Array should not contain the value'); // Fails with custom error message\n```\n\n### I.expectStartsWith\n\nAsserts that the actual value starts with the expected value.\n\n```js\nI.expectStartsWith(actualValue, expectedValueToStartWith, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be checked.\n- `expectedValueToStartWith`: The value expected to be at the start of the actual value.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectStartsWith('hello world', 'hello'); // Passes\nI.expectStartsWith([1, 2, 3], 1); // Passes\nI.expectStartsWith('hello world', 'world', 'String does not start with the value'); // Fails with custom error message\n```\n\n### I.expectNotStartsWith\n\nAsserts that the actual value does not start with the expected value.\n\n```js\nI.expectNotStartsWith(actualValue, expectedValueToNotStartWith, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be checked.\n- `expectedValueToNotStartWith`: The value expected not to be at the start of the actual value.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectNotStartsWith('hello world', 'world'); // Passes\nI.expectNotStartsWith([1, 2, 3], 2); // Passes\nI.expectNotStartsWith('hello world', 'hello', 'String should not start with the value'); // Fails with custom error message\n```\n\n### I.expectEndsWith\n\nAsserts that the actual value ends with the expected value.\n\n```js\nI.expectEndsWith(actualValue, expectedValueToEndWith, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be checked.\n- `expectedValueToEndWith`: The value expected to be at the end of the actual value.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectEndsWith('hello world', 'world'); // Passes\nI.expectEndsWith([1, 2, 3], 3); // Passes\nI.expectEndsWith('hello world', 'hello', 'String does not end with the value'); // Fails with custom error message\n```\n\n### I.expectNotEndsWith\n\nAsserts that the actual value does not end with the expected value.\n\n```js\nI.expectNotEndsWith(actualValue, expectedValueToNotEndWith, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be checked.\n- `expectedValueToNotEndWith`: The value expected not to be at the end of the actual value.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectNotEndsWith('hello world', 'hello'); // Passes\nI.expectNotEndsWith([1, 2, 3], 2); // Passes\nI.expectNotEndsWith('hello world', 'world', 'String should not end with the value'); // Fails with custom error message\n```\n\n### I.expectJsonSchema\n\nAsserts that the target data matches the provided JSON schema using AJV.\n\n```js\nI.expectJsonSchema(targetData, jsonSchema, customErrorMsg = '')\n```\n\n- `targetData`: The data to be validated against the schema.\n- `jsonSchema`: The JSON schema to validate against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nconst schema = {\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    age: { type: 'number' }\n  },\n  required: ['name', 'age']\n};\n\nI.expectJsonSchema({ name: 'John', age: 30 }, schema); // Passes\nI.expectJsonSchema({ name: 'John' }, schema, 'Data does not match schema'); // Fails with custom error message\n```\n\n### I.expectJsonSchemaUsingAJV\n\nAsserts that the target data matches the provided JSON schema using AJV with options.\n\n```js\nI.expectJsonSchemaUsingAJV(targetData, jsonSchema, customErrorMsg = '', ajvOptions = { allErrors: true })\n```\n\n- `targetData`: The data to be validated against the schema.\n- `jsonSchema`: The JSON schema to validate against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n- `ajvOptions`: (Optional) AJV options to customize validation.\n\n**Example:**\n\n```js\nconst schema = {\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    age: { type: 'number' }\n  },\n  required: ['name', 'age']\n};\n\nconst ajvOptions = { allErrors: true, verbose: true };\n\nI.expectJsonSchemaUsingAJV({ name: 'John', age: 30 }, schema, '', ajvOptions); // Passes\nI.expectJsonSchemaUsingAJV({ name: 'John' }, schema, 'Data does not match schema', ajvOptions); // Fails with custom error message\n```\n\n### I.expectHasProperty\n\nAsserts that the target data has the specified property.\n\n```js\nI.expectHasProperty(targetData, propertyName, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `propertyName`: The property expected to be present in the target data.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectHasProperty({ name: 'John', age: 30 }, 'name'); // Passes\nI.expectHasProperty({ name: 'John', age: 30 }, 'address', 'Property not found'); // Fails with custom error message\n```\n\n### I.expectHasAProperty\n\nAsserts that the target data has a specified property.\n\n```js\nI.expectHasAProperty(targetData, propertyName, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `propertyName`: The property expected to be present in the target data.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectHasAProperty({ name: 'John', age: 30 }, 'age'); // Passes\nI.expectHasAProperty({ name: 'John', age: 30 }, 'address', 'Property not found'); // Fails with custom error message\n```\n\n### I.expectToBeA\n\nAsserts that the target data is of the specified type.\n\n```js\nI.expectToBeA(targetData, type, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `type`: The expected type of the target data.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectToBeA('hello', 'string'); // Passes\nI.expectToBeA(123, 'number'); // Passes\nI.expectToBeA('hello', 'number', 'Data is not of the expected type'); // Fails with custom error message\n```\n\n### I.expectToBeAn\n\nAsserts that the target data is of the specified type.\n\n```js\nI.expectToBeAn(targetData, type, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `type`: The expected type of the target data.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectToBeAn([], 'array'); // Passes\nI.expectToBeAn({}, 'object'); // Passes\nI.expectToBeAn([], 'object', 'Data is not of the expected type'); // Fails with custom error message\n```\n\n### I.expectMatchRegex\n\nAsserts that the target data matches the specified regex.\n\n```js\nI.expectMatchRegex(targetData, regex, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `regex`: The regex pattern to match against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectMatchRegex('hello123', /^[a-z]+[0-9]+$/); // Passes\nI.expectMatchRegex('hello', /^[a-z]+[0-9]+$/, 'Data does not match the regex'); // Fails with custom error message\n```\n\n### I.expectLengthOf\n\nAsserts that the target data has the specified length.\n\n```js\nI.expectLengthOf(targetData, length, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `length`: The expected length of the target data.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectLengthOf([1, 2, 3], 3); // Passes\nI.expectLengthOf('hello', 5); // Passes\nI.expectLengthOf([1, 2, 3], 4, 'Data does not have the expected length'); // Fails with custom error message\n```\n\n### I.expectEmpty\n\nAsserts that the target data is empty.\n\n```js\nI.expectEmpty(targetData, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectEmpty([]); // Passes\nI.expectEmpty(''); // Passes\nI.expectEmpty([1, 2, 3], 'Data is not empty'); // Fails with custom error message\n```\n\n### I.expectTrue\n\nAsserts that the target data is true.\n\n```js\nI.expectTrue(targetData, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectTrue(true); // Passes\nI.expectTrue(1 === 1); // Passes\nI.expectTrue(false, 'Data is not true'); // Fails with custom error message\n```\n\n### I.expectFalse\n\nAsserts that the target data is false.\n\n```js\nI.expectFalse(targetData, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectFalse(false); // Passes\nI.expectFalse(1 === 2); // Passes\nI.expectFalse(true, 'Data is not false'); // Fails with custom error message\n```\n\n### I.expectAbove\n\nAsserts that the target data is above the specified value.\n\n```js\nI.expectAbove(targetData, aboveThan, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `aboveThan`: The value that the target data should be above.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectAbove(10, 5); // Passes\nI.expectAbove(10, 15, 'Data is not above the specified value'); // Fails with custom error message\n```\n\n### I.expectBelow\n\nAsserts that the target data is below the specified value.\n\n```js\nI.expectBelow(targetData, belowThan, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `belowThan`: The value that the target data should be below.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectBelow(5, 10); // Passes\nI.expectBelow(15, 10, 'Data is not below the specified value'); // Fails with custom error message\n```\n\n### I.expectLengthAboveThan\n\nAsserts that the target data has a length above the specified value.\n\n```js\nI.expectLengthAboveThan(targetData, lengthAboveThan, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `lengthAboveThan`: The length that the target data should be above.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectLengthAboveThan([1, 2, 3, 4], 3); // Passes\nI.expectLengthAboveThan('hello', 10, 'Data length is not above the specified value'); // Fails with custom error message\n```\n\n### I.expectLengthBelowThan\n\nAsserts that the target data has a length below the specified value.\n\n```js\nI.expectLengthBelowThan(targetData, lengthBelowThan, customErrorMsg = '')\n```\n\n- `targetData`: The data to be checked.\n- `lengthBelowThan`: The length that the target data should be below.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectLengthBelowThan([1, 2, 3], 5); // Passes\nI.expectLengthBelowThan('hello', 3, 'Data length is not below the specified value'); // Fails with custom error message\n```\n\n### I.expectEqualIgnoreCase\n\nAsserts that the actual value is equal to the expected value, ignoring case.\n\n```js\nI.expectEqualIgnoreCase(actualValue, expectedValue, customErrorMsg = '')\n```\n\n- `actualValue`: The actual value to be compared.\n- `expectedValue`: The expected value to compare against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectEqualIgnoreCase('Hello', 'hello'); // Passes\nI.expectEqualIgnoreCase('WORLD', 'world'); // Passes\nI.expectEqualIgnoreCase('Hello', 'World', 'Values are not equal ignoring case'); // Fails with custom error message\n```\n\n### I.expectDeepMembers\n\nAsserts that the members of two arrays are deeply equal.\n\n```js\nI.expectDeepMembers(actualValue, expectedValue, customErrorMsg = '')\n```\n\n- `actualValue`: The actual array to be compared.\n- `expectedValue`: The expected array to compare against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectDeepMembers([{ a: 1 }, { b: 2 }], [{ a: 1 }, { b: 2 }]); // Passes\nI.expectDeepMembers([{ a: 1 }, { b: 2 }], [{ a: 1 }, { b: 3 }], 'Arrays are not deeply equal'); // Fails with custom error message\n```\n\n### I.expectDeepIncludeMembers\n\nAsserts that an array is a superset of another array.\n\n```js\nI.expectDeepIncludeMembers(superset, set, customErrorMsg = '')\n```\n\n- `superset`: The array expected to be a superset.\n- `set`: The array expected to be included in the superset.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nI.expectDeepIncludeMembers([{ a: 1 }, { b: 2 }, { c: 3 }], [{ a: 1 }, { b: 2 }]); // Passes\nI.expectDeepIncludeMembers([{ a: 1 }, { b: 2 }], [{ a: 1 }, { c: 3 }], 'Superset does not include all members'); // Fails with custom error message\n```\n\n### I.expectDeepEqualExcluding\n\nAsserts that the members of two JSON objects are deeply equal, excluding some properties.\n\n```js\nI.expectDeepEqualExcluding(actualValue, expectedValue, fieldsToExclude, customErrorMsg = '')\n```\n\n- `actualValue`: The actual JSON object to be compared.\n- `expectedValue`: The expected JSON object to compare against.\n- `fieldsToExclude`: The properties to exclude from the comparison.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nconst actual = { a: 1, b: 2, c: 3 };\nconst expected = { a: 1, b: 2, c: 4 };\nI.expectDeepEqualExcluding(actual, expected, ['c']); // Passes\nI.expectDeepEqualExcluding(actual, expected, ['b'], 'Objects are not deeply equal excluding properties'); // Fails with custom error message\n```\n\n### I.expectMatchesPattern\n\nAsserts that a JSON object matches a provided pattern.\n\n```js\nI.expectMatchesPattern(actualValue, expectedPattern, customErrorMsg = '')\n```\n\n- `actualValue`: The actual JSON object to be checked.\n- `expectedPattern`: The pattern to match against.\n- `customErrorMsg`: (Optional) Custom error message to display if the assertion fails.\n\n**Example:**\n\n```js\nconst actual = { name: 'John', age: 30 };\nconst pattern = { name: 'John' };\nI.expectMatchesPattern(actual, pattern); // Passes\nI.expectMatchesPattern(actual, { name: 'Doe' }, 'Object does not match the pattern'); // Fails with custom error message\n```\n\n---\n\nThis documentation provides a comprehensive overview of the `ExpectHelper` class and its methods. Each method is designed to perform specific assertions, making it easier to write and maintain tests. The examples provided demonstrate how to use each method effectively.\n\n\n### License MIT\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeceptjs%2Fexpect-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeceptjs%2Fexpect-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeceptjs%2Fexpect-helper/lists"}