01What is Test Case Generator?
Most bugs we chase in review hide in the inputs nobody thought to try: an empty string, a null from a JSON body, a NaN that slipped past a parseInt. This tool turns a function signature into a checklist of those inputs, so you can plan the tests before you write them. You paste one line, such as function login(email: string, password: string): boolean, and press Generate. The parser reads plain and async function declarations, const arrow functions and class method signatures with modifiers like public or static. It splits parameters only on top-level commas, so a type like Record<string, number> stays in one piece. Destructured parameters become arg1, arg2 and so on. Rest parameters drop their three dots. A parameter counts as optional when it has a question mark or a default value, and a bare default such as retries = 3 is read as a number. From there the rules are simple and predictable. Every plan opens with one happy-path case built from placeholder values: "valid_test_value" for strings, 42 for numbers, true for booleans and [item1, item2] for arrays. Anything else gets validMockObject. Each parameter then gets a null case, and the expected result depends on the type. If the type is a union with null or undefined, null should be accepted. If the parameter is optional, it should be treated as missing. Otherwise it should throw or return an error. Strings add empty, whitespace-only, a 10,000-character value, a script tag and "Zoë 😀". Numbers add 0, -1, 0.5, Number.MAX_SAFE_INTEGER, NaN and Infinity. Booleans get true and false, and arrays get an empty list and a one-item list. When there are optional parameters, a final case leaves them all out. Each case changes only one parameter and keeps the rest valid, which follows the usual one-factor-at-a-time approach from boundary value analysis. Here's a quick run. The signature calculateDiscount(price: number, percentage: number, maxDiscount?: number): number gives 23 cases. That is one happy path, seven per parameter and one case without maxDiscount. The null case for maxDiscount says to treat it as missing, while the null cases for price and percentage expect an error. Now the honest part. The tool only reads the signature text and never runs your code, so the expected behaviour lines are prompts for you to confirm. Custom types like User or Opts only get a null case. Generics, enums and string literal unions are not expanded into their own values. If the line can't be parsed, you see a short message with the accepted forms. Copy All gives you the plan as text with JSON inputs, ready to turn into test.each tables.
Developers writing unit tests for TypeScript or JavaScript functions who want a quick list of null, empty and boundary inputs before they start. The tool runs entirely in your browser, so your data never leaves your device.
02How to use Test Case Generator
- Type or paste one signature into the Function Signature field, or pick one of the three examples to load it instantly.
- Press Generate or hit Enter.
- Read the cases, grouped by category such as Happy Path, Null/Undefined, Empty Values, Boundary, Special Characters and Optional, each with a priority badge.
- If you see the "Couldn't read a function signature" message, rewrite the line in one of the forms it lists.
- Click Copy All and paste the plan into your test file or ticket.
03Worked examples
- Input:
function login(email: string, password: string): boolean - Result:
13 cases. Happy path {email: "valid_test_value", password: "valid_test_value"} -> "Should return a valid boolean", then 6 cases per parameter: null, empty, whitespace, 10,000 chars, <script>, "Zoë 😀" - Trimmed to the case names. Each case changes one parameter and leaves the other valid.
- Input:
function calculateDiscount(price: number, percentage: number, maxDiscount?: number): number - Result:
23 cases. "maxDiscount is null" -> "Should treat as missing or handle gracefully"; last case "all optional params omitted" with {price: 42, percentage: 42} - The null case for price expects an error instead, because price is required.
- Input:
sum(xs: number[]): number - Result:
4 cases: happy path {xs: [item1, item2]}, xs is null, xs is an empty array, xs has one item - Array parameters get list cases, not the six number cases.
- Input:
find(id: string | null): User - Result:
7 cases; "find - id is null" -> "Should accept null (the type allows it)" - Because the type includes null, a null input is expected to be accepted.
- Input:
function cfg(map: Record<string, number>, retries = 3): void - Result:
10 cases. Happy path {map: validMockObject, retries: 42} -> "Should complete without throwing" - The generic type stays whole, and retries is read as an optional number from its default.
- Input:
const f = ({a, b}: Opts, ...rest: string[]) => void - Result:
5 cases with parameters named arg1 and rest: null for each, plus rest as an empty array and with one item - Destructured parameters get a placeholder name, and rest parameters lose their dots.
04Common use cases
- Planning Jest or Vitest cases for a pricing helper like calculateDiscount before writing it test-first
- Checking a pull request's test file against the generated list to spot missing null or NaN cases
- Writing a QA checklist for an API handler whose body fields arrive as untrusted JSON
- Showing a junior developer why an empty string and a whitespace-only string deserve separate tests
- Seeding a test.each table for a function that takes an array, with empty and single-item lists ready to go
- Reviewing which parameters of a public library function are optional and what happens when callers omit them
05Tips
- Write string | null in the signature when null is legal, and the null case flips from expecting an error to expecting acceptance.
- A default value with no annotation still works: retries = 3 is treated as a number and gets all six number cases.
- Use type keywords like string and number[] rather than aliases. An alias such as Email gets only a null case because the tool can't see what it stands for.
- Agree on what NaN, -1 and 0.5 should do in the spec first, otherwise your assertions will just copy whatever the code happens to do.
06Related concepts
Edge cases, Unit testing, Test-driven development, Parametrized tests, Input validation.
Frequently Asked Questions
What is Test Case Generator?
Test Case Generator is a free, browser-based developer tool on AIDToolStack. Generate test cases from function signatures It requires no installation or sign-up and works entirely in your browser.
Is Test Case Generator free to use?
Yes. No sign-up, no fees and no usage cap.
Does Test Case Generator store my data?
No. It runs in your browser; nothing is uploaded.