cartesi / explorer

Cartesi Blockchain Explorer
https://explorer.cartesi.io
Apache License 2.0
9 stars 12 forks source link

Optimize unit tests for apps/rollups #17

Closed nevendyulgerov closed 1 year ago

nevendyulgerov commented 1 year ago

πŸ“„ Context

We noticed that unit tests take a lot of time to execute while not containing anything heavy in terms of computations.

Most of the time, those tests contain some mocks and simple checks that should be rather fast. Mocks are stored in memory and we are not calling any third-party services so the large amounts of time required for tests to execute are not justified. This also impacts our builds as they are slower than expected.

βœ”οΈ Solution

There are multiple things we can do to improve unit tests speed. An example is to optimize imports since jest (our test runner) takes more time to process large imports than specific ones.

Example from packages/ui:

This is slower:

import { StakePlusIcon } from '../../src/components';

than this:

import { StakePlusIcon } from '../../src/components/Icons';

πŸ“ˆ Subtasks

🎯 Definition of Done