You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Optimize imports. Opt in for specific imports than global ones.
Investigate if we can run only new tests or tests for which the underlying components/modules have changed with https://jestjs.io/docs/cli#--onlychanged. This is for test:ci command.
📄 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:
than this:
📈 Subtasks
test:ci
command.--runInBand
flag fortest:ci
. For reference - https://jestjs.io/docs/cli#--runinband.🎯 Definition of Done
The text was updated successfully, but these errors were encountered: