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-4/

Assertion Library Performance Benchmarker

Build a utility that measures the performance characteristics of an assertion enhancement library when used with and without custom messages.

@generates

Requirements

Create a benchmarking utility that measures execution time for assertions in two scenarios:

  1. Baseline scenario: assertions without custom messages (using the library's basic functionality)
  2. Enhanced scenario: assertions with custom messages (using the library's enhanced functionality)

The utility should:

  • Run a configurable number of assertions (default: 10,000) in each scenario
  • Measure and record execution time for each scenario in milliseconds
  • Calculate the performance difference between enhanced and baseline scenarios
  • Return all timing metrics and calculated differences

Implementation Details

  • Use performance.now() or similar high-resolution timing for accurate measurements
  • Run the same type of assertions in both scenarios (e.g., simple equality checks)
  • For the baseline scenario: use assertions without providing a custom message parameter
  • For the enhanced scenario: use assertions with a custom message parameter
  • Calculate the overhead percentage as: ((enhancedTime - baselineTime) / baselineTime) * 100

Test Cases

  • Running benchmark with default iterations returns valid timing data for both scenarios @test
  • Benchmark results include baselineTime, enhancedTime, and overheadPercent properties @test
  • Running benchmark with custom iteration count (e.g., 5000) uses the specified count @test

API

/**
 * Runs performance benchmarks comparing assertions with and without custom messages
 * @param {number} iterations - Number of assertions to execute in each scenario (default: 10000)
 * @returns {Object} Benchmark results
 * @returns {number} return.baselineTime - Execution time for assertions without custom messages (ms)
 * @returns {number} return.enhancedTime - Execution time for assertions with custom messages (ms)
 * @returns {number} return.overheadPercent - Performance overhead percentage
 */
function runBenchmark(iterations = 10000) {
  // IMPLEMENTATION HERE
}

module.exports = { runBenchmark };

Dependencies { .dependencies }

jest-expect-message { .dependency }

Provides custom error messages for Jest assertions.

@satisfied-by

Install with Tessl CLI

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

tile.json