Skip to content

Add New Assertions for Enhanced Testing Capabilities #63

@OlehBabenkoo

Description

@OlehBabenkoo

I would like to propose adding the following new assertions to the test runner. These assertions will expand its functionality, make it more versatile, and align with modern testing frameworks. Below is the list of proposed assertions along with a brief description of each:

  • 1. .toBeType()

    Validates the type of a value, for example, whether it's a string, object, number, etc.

  • 2. .toBeInstanceOf()

    Checks if an object is an instance of a specific class.

  • 3. .toResolve()

    Ensures that a promise resolves successfully.

  • 4. .toReject()

    Ensures that a promise is rejected with an error.

  • 5. .toDeepEqual()

    Performs deep equality comparison of objects or arrays (useful for testing nested structures).

  • 6. .toBeSorted()

    Validates that an array is sorted either in ascending or descending order.

  • 7. .toBeUnique()

    Confirms that all elements in an array are unique (no duplicates).

  • 8. .toRespondWithStatus()

    Verifies that an HTTP response has the expected status code.

  • 9. .toHaveJSONBody()

    Validates that an HTTP response body contains valid JSON and optionally verifies its structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions