# Unit testing explained, with Jest and Vitest

> Unit testing explained, with examples. Run your Jest or Vitest suites against a pinned code revision and inspect the native results and remaining gaps.

Source: https://cueapril.com/testing/unit-testing
Updated: 2026-09-30
Index: https://cueapril.com/llms.txt

## What is unit testing?

Unit testing checks the smallest pieces of your code, such as a single function, in isolation. Focused unit tests run quickly, and a failing one points to the function whose behaviour broke.

Your repository already contains useful knowledge about expected behaviour. Cue April runs supported unit tests as part of a reviewed quality plan, with the exact source revision, native results and incomplete work available for inspection.

## Start with tests your team already recognises.

Repository inspection reads supported configuration and selected test files at a pinned commit. The setup proposal shows what was discovered and what remains outside the inspection. The existing-test onboarding path selects a small baseline by default, giving your team a bounded starting point to review before approving execution and its cost.

## Preserve the result your framework produced.

Supported Jest, Vitest and declared command adapters retain native test evidence. The adapter approach requires its runtime and tools to be installed in the qualified runner image. Missing tools, partial reports and skipped work remain visible. Where coverage is declared, the report preserves the available native counts and identifies incomplete evidence.

- Review the detected suites and exact tested source.
- Keep failures and incomplete results attached to their run.
- Combine unit checks with approved API, property and mutation methods.

## Use a baseline to plan the next checks.

A baseline can show how the selected existing tests behaved. It cannot establish that every requirement was tested or grant release readiness on its own. An evaluation reviews your framework, project layout, environment and desired scope so the first result leads to a useful next decision. Additional methods can challenge behaviours the current suite leaves unchecked.

By Cue April. Updated 2026-09-30.

## Questions

### Does every language work automatically?

Support depends on the available native engine or declared adapter and its qualified toolchain. An arbitrary command alone does not establish complete language or framework support.

### Can passing unit tests approve my release?

They contribute evidence for their tested scope. Required methods, current source identity and outstanding obligations still matter, and your team retains the release decision.

### What is an example of a unit test?

A unit test for a delivery rule might call the shipping calculation with an order just under the free-delivery threshold and assert that a charge is applied. It sets up one input, calls one function and checks one expected result.

### What are the three As of unit testing?

Arrange, Act and Assert. Arrange sets up the inputs and state, Act calls the code under test and Assert checks the result. Keeping the three steps distinct makes a failing test much easier to read and fix.

### What is the difference between unit and functional testing?

A unit test checks one small piece of code in isolation. A functional test checks that a feature does what users need, often across several parts of the system. Cue April can run both, through unit, API, Playwright and Gherkin checks.

## Related

- [Mutation testing](https://cueapril.com/testing/mutation-testing): Run a Stryker mutation testing example. Inspect a surviving delivery-boundary mutant, add the missing assertion and compare native reports.
- [Property-based testing](https://cueapril.com/testing/property-based-testing): Run a fast-check property-based testing example: find a delivery-rule boundary fault, replay its seed and counterexample, and verify the fix.
- [Pull request testing](https://cueapril.com/use-cases/pull-request-testing): Test a pull request against agreed requirements, keep the tested revision and native results, and review a practical checklist before merging.
