tessl install tessl/npm-jest-circus@29.7.0The next-gen flux-based test runner for Jest that provides test framework globals and event-driven test execution
Agent Success
Agent success rate when using this tile
82%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.91x
Baseline
Agent success rate without this tile
43%
Build a test suite for an asynchronous data fetcher utility that validates promise-based operations.
You're testing a data fetching utility that makes asynchronous requests to retrieve user data. The utility returns promises that either resolve with data or reject with errors based on various conditions.
Create tests for a DataFetcher class with the following methods:
fetchUser(id) - Returns a promise that resolves with user data when given a valid user ID (positive integer), or rejects with an error for invalid IDs (negative or zero).
fetchMultipleUsers(ids) - Returns a promise that resolves with an array of user objects when all IDs are valid, or rejects if any ID is invalid.
fetchUserWithTimeout(id, timeout) - Returns a promise that resolves with user data if the fetch completes within the timeout, or rejects with a timeout error otherwise.
Write tests that verify:
Your test suite must include the following test cases:
id and name properties @test@generates
class DataFetcher {
/**
* Fetches user data for a given user ID.
* @param {number} id - User ID (must be positive)
* @returns {Promise<{id: number, name: string}>} Promise resolving to user object
*/
fetchUser(id) {
// Implementation simulates async fetch
}
/**
* Fetches multiple users by their IDs.
* @param {number[]} ids - Array of user IDs
* @returns {Promise<Array<{id: number, name: string}>>} Promise resolving to array of users
*/
fetchMultipleUsers(ids) {
// Implementation simulates async fetch for multiple users
}
/**
* Fetches user with a timeout constraint.
* @param {number} id - User ID
* @param {number} timeout - Timeout in milliseconds
* @returns {Promise<{id: number, name: string}>} Promise resolving to user object
*/
fetchUserWithTimeout(id, timeout) {
// Implementation simulates async fetch with timeout
}
}
module.exports = { DataFetcher };Provides testing framework and assertion capabilities.