Unit testing
Unit testing is a testing method where application units are tested in isolation without depending on other parts.
For unit testing, we will use Jest, which is the most popular framework for testing JavaScript applications.
In our application, we will unit test the notifications store.
Let’s open the src/stores/notifications/__tests__/notifications.test.ts
file and add the following:
import { notificationsStore, Notification, } from '../notifications'; const notification = { id: '123', title: 'Hello World', type: 'info', message: 'This is a notification', } as Notification; describe('notifications store', () => { it('should show and dismiss notifications', () => { // 1 expect( notificationsStore.getState().notifications...