CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-jest-expect-message

Add custom message to Jest expects

Overall
score

99%

Overview
Eval results
Files

task.mdevals/scenario-7/

Async Validator Test Suite

A comprehensive test suite for an async validation service that validates user data against business rules. The test suite must provide clear, informative error messages for each test case using custom assertion messages.

Capabilities

Handles successful async validations

  • Validates that a promise resolves to a user object with an id property when valid data is provided @test
  • Validates that a promise resolves to a value not equal to null when processing valid email addresses @test

Handles validation failures with rejections

  • Ensures that validation rejects with an error containing "invalid email" when email format is incorrect @test
  • Ensures that validation does not resolve successfully (must reject) when age is negative @test

Implementation

@generates

API

/**
 * Validates user data asynchronously
 *
 * @param {Object} userData - User data to validate
 * @param {string} userData.email - User email address
 * @param {number} userData.age - User age
 * @returns {Promise<Object>} Resolves with validated user object containing id
 * @throws {Error} Rejects with validation error if data is invalid
 */
async function validateUser(userData) {
  // IMPLEMENTATION HERE
}

module.exports = { validateUser };

Dependencies { .dependencies }

jest-expect-message { .dependency }

Provides enhanced assertion messages for Jest tests.

Install with Tessl CLI

npx tessl i tessl/npm-jest-expect-message

tile.json