Testing with Jest and Mock XP
Contents
This tutorial introduces you to the Jest testing framework, and how to integrate it in an Enonic application.
Introduction
Jest is a highly adopted testing framework that supports TypeScript, mocking, and a lot, lot more.
A special feature of this setup is that tests can be executed standalone, independently of Enonic XP. Thus, the tests will finish faster and be more flexible to execute.
For more details, visit the Jest documentation. |
This guide will show you how to:
-
Create a Project with Jest environment already set up.
-
Write a simple test without any mocks
-
Write a test for server-side code manually mocking Java libraries
-
Write a test for server-side code using Mock XP
-
Write a test for client-side code
Additional reading
If you want to learn how to add Jest to an existing project, read the Testing chapter of the TypeScript Starter documentation.