Parameterised tests for Jest that enable running the same test multiple times with different data sets using arrays or tagged template literals
85
A service that sends notifications to users via different channels (email and SMS). The service should be testable by mocking the external notification providers.
@generates
/**
* Sends a notification to a user through the specified channel.
*
* @param {string} userId - The ID of the user to notify
* @param {string} message - The notification message
* @param {string} type - The notification channel ("email" or "sms")
* @returns {Promise<{success: boolean, error?: string}>} The result of the notification attempt
* @throws {Error} Throws an error if the notification type is not supported
*/
async function sendNotification(userId, message, type) {
// IMPLEMENTATION HERE
}
module.exports = {
sendNotification
};Provides testing framework with module mocking capabilities.
External module that sends email notifications. Exposes a sendEmail(userId, message) function that returns a Promise resolving to {sent: true} on success.
@generates
External module that sends SMS notifications. Exposes a sendSMS(userId, message) function that returns a Promise resolving to {sent: true} on success.
@generates
Install with Tessl CLI
npx tessl i tessl/npm-jest-eachdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10