Unit Test Generator Assistant

Find the inputs worth testing (empty, zero, negative, huge, null, Unicode, errors) and get a test file skeleton; an optional on-device AI writes complete tests.

Körs i din webbläsare. Dina filer lämnar aldrig din enhet. Se hur du kontrollerar det

…

Så gör du

  1. 1
    Paste the function

    Paste one or more functions into the editor; the first one is selected.

  2. 2
    Choose function and framework

    Pick the function, the test framework and the import path.

  3. 3
    Review edge cases

    Untick cases that do not apply and read why each one matters.

  4. 4
    Copy the skeleton

    Open Test skeleton, copy or download it and fill in the expected values.

  5. 5
    Optionally load AI

    In the AI tab read the size notice and press Load the AI model.

  6. 6
    Generate and review

    Press Generate tests, then run and correct the draft in your project.

Om det här verktyget

Writing the first tests for a function is mostly about asking the right questions: what happens with an empty list, a zero, a negative number, a string of spaces, an emoji, a null, an enormous input? Testers formalise this as boundary value analysis and equivalence partitioning. This assistant applies those ideas automatically. It reads the function's parameters, their types, default values and names, and looks at the body for risky operations such as division, indexing, parsing, regular expressions, loops, network calls and thrown errors. From that it builds a list of edge cases with the reason each one matters, and writes a ready test file for Vitest, Jest, node:test or pytest. A small coding model can also run in your browser and write complete tests from the same list.

Who this is for

Developers adding tests to existing code, students learning to test, reviewers checking that a pull request covers the tricky inputs, and anyone facing a function with zero tests.

How parameter kinds are guessed

Type annotations come first: number, string, arrays and lists, booleans, dates, callbacks, objects and dicts. Without types, default values and names help: count, price and index suggest numbers; name, email and path strings; items and values lists; is and has prefixes booleans; options and config objects. The body is a last clue: a parameter that is divided or multiplied is numeric, one that is trimmed or split is a string.

Which cases are added

For each parameter, the typical value is varied one at a time: zero, minus one, a billion, a fraction and NaN for numbers; empty, whitespace, accented text with emoji and a 10,000-character string for text; empty, single, duplicated and very large lists. Null or None is tried for typed parameters, and parameters with defaults are also tested when omitted. Body cues add division by zero, index out of range, the error path when the code throws, rejected promises for async code, non-numeric strings for parsing, regex special characters and I/O failures that should be mocked.

The skeleton

Each selected case becomes one test with a comment explaining why it exists. JavaScript and TypeScript use describe and test with toEqual, or assert.deepEqual for node:test; error cases use rejects or assert.rejects. Python uses pytest with a parametrize table for value cases and pytest.raises for error cases. Expected values are deliberately left as TODO.

Why expected values are blank

A generator can see what the code does, but not what it should do. Filling expected values from the current output would only freeze existing bugs into tests. You decide the right answers from the specification, then run the tests.

The local AI option

With your consent, Qwen2.5-Coder-0.5B-Instruct (Apache-2.0, about 555 MB) is downloaded once from the Hugging Face CDN, cached by the browser and run on your device with WebGPU or WebAssembly. Given the function, the framework and the selected cases, it drafts complete tests with expected values. Your code never leaves the device.

Worked example

For parsePrice(text: string, currency = "EUR"), which strips symbols, parses a float and throws on empty or invalid input, the assistant lists 16 cases, including text = "", text = " ", currency omitted, invalid input raises an error, non-numeric string and regex special characters. The Vitest skeleton imports parsePrice and has one test per case.

Limits

Parsing is pattern-based, not a full compiler, so unusual syntax, decorators or overloaded functions may be misread; pick the function from the list if needed. The AI model is small and can be wrong about expected values or invent helper functions. It needs a recent browser and around 4 GB of memory, and is not a substitute for reviewing and running the tests.

Lösta exempel

parsePrice(text, currency = "EUR"): 16 edge cases and a Vitest file with one test per case.

I korthet

Vanliga frågor

Which languages are supported?

JavaScript and TypeScript (functions, arrow functions, methods) and Python functions. Other languages get line-based parsing with fewer cues.

Why are expected results TODO?

Because only the specification knows the right answer; copying today's output would turn bugs into tests.

Is the AI model required?

No. Edge cases and skeletons are rule-based and work without downloading anything.

Where does the model run?

In your browser, on your device. The model files come from the Hugging Face CDN; your code is not sent anywhere.

Can I remove cases I do not need?

Yes. Untick them in Edge cases and the skeleton and AI prompt update immediately.

What is boundary value analysis?

A testing technique that picks inputs at the edges of valid ranges, such as 0, 1 and the maximum, where off-by-one errors hide.

Helt gratisIngen avgift, ingen registrering
Filer förblir privataAllt körs i din webbläsare
Enkelt på ditt språkFinns på många språk