CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-jest-each

Parameterised tests for Jest that enable running the same test multiple times with different data sets using arrays or tagged template literals

85

1.10x
Overview
Eval results
Files

task.mdevals/scenario-1/

Payment Processing System

Build a payment processing system that handles payments through different providers. The system should support testing various payment scenarios using mock implementations.

Requirements

Implement a payment processor with the following functionality:

  • A function processPayment that accepts an amount and provider name, then calls the appropriate provider function
  • Three provider functions: creditCardProvider, paypalProvider, and cryptoProvider
  • Each provider function accepts an amount and returns a payment result with status and transaction ID
  • Proper error handling when providers fail

Test Cases

Write tests that verify:

  • Processing a payment with a credit card provider returns success @test
  • Processing a payment with PayPal provider returns success @test
  • Processing a payment when provider throws an error is handled correctly @test
  • Multiple sequential payments can have different results (first succeeds, second fails) @test

@generates

API

/**
 * Processes a payment using the specified provider
 * @param {number} amount - The payment amount
 * @param {string} provider - The payment provider name
 * @returns {Promise<{status: string, transactionId: string}>} Payment result
 */
async function processPayment(amount, provider) {
  // Implementation
}

/**
 * Credit card payment provider
 * @param {number} amount - The payment amount
 * @returns {Promise<{status: string, transactionId: string}>} Payment result
 */
async function creditCardProvider(amount) {
  // Implementation
}

/**
 * PayPal payment provider
 * @param {number} amount - The payment amount
 * @returns {Promise<{status: string, transactionId: string}>} Payment result
 */
async function paypalProvider(amount) {
  // Implementation
}

/**
 * Crypto payment provider
 * @param {number} amount - The payment amount
 * @returns {Promise<{status: string, transactionId: string}>} Payment result
 */
async function cryptoProvider(amount) {
  // Implementation
}

module.exports = {
  processPayment,
  creditCardProvider,
  paypalProvider,
  cryptoProvider
};

Dependencies { .dependencies }

jest { .dependency }

Provides testing framework and mocking capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-jest-each

tile.json