{"id":11140,"library":"jest-in-case","title":"Jest In Case: Parameterized Tests","description":"jest-in-case is a utility for the Jest testing framework that simplifies the creation of parameterized tests. It allows developers to define a single test function (`tester`) and supply multiple sets of input data (`testCases`) as either an array of objects or an object whose keys serve as test names. This dramatically reduces boilerplate when testing a function or component with numerous input variations. The package helps organize tests by automatically generating named test cases using Jest's `test` function, and supports `test.only` and `test.skip` via special `only` and `skip` properties within test cases. The latest version, 1.0.2, was published on September 8, 2017, making it an effectively abandoned project. This means it has not been updated in over nine years and is likely incompatible with recent major versions of Jest (e.g., Jest 30) and modern Node.js environments. There is no active release cadence, and it lacks contemporary features like native TypeScript support.","status":"abandoned","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/thinkmill/jest-in-case","tags":["javascript","jest","test","testing"],"install":[{"cmd":"npm install jest-in-case","lang":"bash","label":"npm"},{"cmd":"yarn add jest-in-case","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-in-case","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a Jest utility and implicitly requires Jest to run tests. Given its age (last updated 2017), it is likely only compatible with much older Jest versions (e.g., pre-Jest 20).","package":"jest","optional":false}],"imports":[{"note":"The 'cases' function is the default export. Using named import syntax will result in an error in ESM contexts.","wrong":"import { cases } from 'jest-in-case';","symbol":"cases","correct":"import cases from 'jest-in-case';"},{"note":"For CommonJS environments, 'cases' is the module.exports value. Destructuring will fail.","wrong":"const { cases } = require('jest-in-case');","symbol":"cases","correct":"const cases = require('jest-in-case');"}],"quickstart":{"code":"/* file: math.js */\nexport function add(augend, addend) {\n  return augend + addend;\n}\n\nexport function subtract(minuend, subtrahend) {\n  return minuend - subtrahend;\n}\n\n/* file: math.test.js */\nimport cases from 'jest-in-case';\nimport { add, subtract } from './math';\n\ndescribe('Math operations', () => {\n  cases('add(augend, addend) should return correct total', opts => {\n    expect(add(opts.augend, opts.addend)).toBe(opts.total);\n  }, [\n    { name: '1 + 1 = 2', augend: 1, addend: 1, total: 2 },\n    { name: '2 + 1 = 3', augend: 2, addend: 1, total: 3 },\n    { name: '3 + 1 = 4', augend: 3, addend: 1, total: 4 },\n  ]);\n\n  cases('subtract(minuend, subtrahend) should return correct difference', opts => {\n    expect(subtract(opts.minuend, opts.subtrahend)).toBe(opts.difference);\n  }, {\n    '5 - 2 = 3': { minuend: 5, subtrahend: 2, difference: 3 },\n    '10 - 7 = 3': { minuend: 10, subtrahend: 7, difference: 3 }\n  });\n\n  cases('async test example', async ({ input, expected }) => {\n    const result = await Promise.resolve(input * 2);\n    expect(result).toBe(expected);\n  }, [\n    { name: 'doubles 5 to 10', input: 5, expected: 10 },\n    { name: 'doubles 10 to 20', input: 10, expected: 20 }\n  ]);\n});","lang":"javascript","description":"This quickstart demonstrates how to use `jest-in-case` with both array and object-based test cases, including an asynchronous test example, to run multiple variations of the same test against `add` and `subtract` functions."},"warnings":[{"fix":"Consider migrating to native Jest parameterized testing (`test.each`) or other actively maintained alternatives like `jest-when` for modern Jest setups.","message":"This package is effectively abandoned, with its last release (1.0.2) in September 2017. It is highly unlikely to be compatible with modern versions of Jest (e.g., Jest 30), Node.js, or contemporary module systems (ESM). Using it may lead to critical failures or unexpected behavior in newer environments.","severity":"breaking","affected_versions":">=1.0.3 (hypothetical), or any version with modern Jest/Node.js"},{"fix":"Avoid using `name`, `only`, or `skip` as keys for your test data within the test case objects. Choose alternative property names for your test parameters.","message":"The `name`, `only`, and `skip` properties are reserved keywords within test case objects passed to `jest-in-case`. If you include these properties with custom values, they will be overridden or used by `jest-in-case` for test naming and conditional execution, potentially leading to unexpected test behavior or data loss.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For TypeScript projects, it's strongly recommended to use Jest's built-in `test.each` feature or other modern alternatives that provide native TypeScript support for parameterized tests.","message":"Due to its age, `jest-in-case` does not ship with TypeScript type definitions, nor does it officially support TypeScript. While it might be used in a TypeScript project with `@ts-ignore` or manually created declaration files, this is not officially supported and can lead to type safety issues.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `cases` is imported as a default export: `import cases from 'jest-in-case';` for ESM or `const cases = require('jest-in-case');` for CommonJS. Also, verify that `jest-in-case` is compatible with your project's module system and Jest version.","cause":"Attempting to use `jest-in-case` with incorrect import syntax (e.g., named import for a default export) or in an environment where module resolution fails due to its age.","error":"TypeError: cases is not a function"},{"fix":"Ensure Jest is properly installed (`npm install --save-dev jest`), configured, and that `jest-in-case` is running within a standard Jest test file. Given the package's age, this might indicate fundamental incompatibility with your Jest setup.","cause":"This error can occur if Jest is not correctly configured or if a very old version of Jest is used, where `expect` might not be globally available or set up within the test environment when `jest-in-case` runs its callback.","error":"Error: expect is not defined"}],"ecosystem":"npm"}