Skip to content
Visit KlexSign on GitHub
Set theme to dark (⇧+D)

KlexSign Test

Tests are important to ensure that the product is working as expected. We know, that test can be a bit tricky, but we want to help you to get started.

Here are templates and tricks to create your test for KlexSign.


Testing the backend is very complicated. We have a lot of different tools to test the backend.

Firstly for small tasks like unit tests we can use the Jest testing framework. It is installed and configired by default in KlexSign.

The Backend is separated into different test suites.

Repository Test

We want ensure, that every defined mongodb query work as expected. So every new query should be tested. Please extend the test if you add a new query.

We spin up a new clean mongodb-memory-server. The database connection client is mocked and defined in mockDatabaseConnection.ts. On each test we drop the collection to ensure that all tests can pass without any impact.

So don't create tests that required or depend on datasets that not inserted / modified in the same test. We know, that this slowes down the tests. But this is the only way we can ensure that nothing will break if we change the datasets or the order of the tests.

This can save us time and nights debugging in the future.

Generally we don't want to test the database connection, but we want to test the database queries. So don't mock the repository or single queries.

CreateDate Yeah, thats tricky. The date of creation are generated in the DTO. So it is in each condition different. We don't want to mock the Class, so we ignore the Date on all tests.

Controller Tests

coming soon :D


On the frontend, we use only integration tests. That is not a rule but nobody write tests for the frontend in the past. :D

The framework Testcafe is used to create tests.

Please ensure, that you onle create Selector for ids. This is the only way to ensure, that you are testing the right element and nobody can break your tests.