BASE

Jest

Jest

Test automation · Free

A JavaScript test framework with test isolation, mocks, snapshot checks, and coverage reports for verifying code behavior.

Also known as: jestjs/jest; jest-testing; jestjs

Resource illustration: Jest

Open resource ↗

What you can use for free

Code and local use under MIT.

Paid features and costs

Compute, your own hosting, and external services are paid for separately if selected.

Access and limitations

Code and local use under MIT. Compute, your own hosting, and external services are paid for separately if selected.

Use cases

  • Capture JavaScript module behavior with tests
  • Compare actual results and required snapshots with expectations

Example workflow

A possible workflow; this is not a report of hands-on testing.

Capture JavaScript module behavior with tests.

Before you start

  • One important workflow and its expected result.
  • A test environment with controlled data.

Steps

  1. Define unit tests and isolate external dependencies with mocks.
  2. Compare actual results and required snapshots with expectations.
  3. Run the check locally and save the report in CI.

Check your result

  • The check detects a deliberately broken workflow.
  • The result can be reproduced without depending on a personal session.

Choosing Jest

Capture JavaScript module behavior with tests

Choose this when

  • Capture JavaScript module behavior with tests
  • Compare actual results and required snapshots with expectations

Requirements

  • If the original call is unacceptable, set mockImplementation for spyOn; restore modified methods after the test.

Things to consider

  • Costs and limits of free use: Compute, your own hosting, and external services are paid for separately if selected.
  • Terms of use: MIT: code; dependencies have separate licenses.
  • spyOn tracks calls but invokes the original implementation by default, including its side effects.

Frequently asked questions

What can you use for free in Jest?

Code and local use under MIT.

What additional costs might arise with Jest?

Compute, your own hosting, and external services are paid for separately if selected.

What terms of use matter for Jest?

MIT: code; dependencies have separate licenses.

How do you get started with Jest?

Define unit tests and isolate external dependencies with mocks. Compare actual results and required snapshots with expectations. Run the check locally and save the report in CI.

Why did jest.spyOn not stop the actual method call?

spyOn invokes the original method by default. To replace behavior, use mockImplementation or the corresponding mock. mockRestore or restoreAllMocks restore originals after the test; observing calls does not block them.

License

MIT: code; dependencies have separate licenses.

MIT — permissive license

You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.

License terms

Technologies and topics

  • Jest
  • test
  • Development

Sources

Other resources