Skip to content

The component's test for closing by timeout failed #167

@Smistav

Description

@Smistav

import {act, render, screen} from '@testing-library/react'
import {ReactNotifications, Store} from "react-notifications-component";

jest.useFakeTimers();
describe('notification types hide after 2 second', () => {
test('should hide info',
async () => {
render()
act(() => {
Store.addNotification({
type: 'info', message: 'notification info',
container: "bottom-right", dismiss: {
duration: 2000
}
})
})
const notificationBefore = await screen.findByText('notification info')
expect(notificationBefore).toBeInTheDocument()
act(() => {
jest.advanceTimersByTime(3000)
})
const notificationAfter = await screen.findByText('notification info')
expect(notificationAfter).not.toBeInTheDocument()
})
})
jest.clearAllTimers()

The notification is not removed from the DOM even if you try to apply the method Store.removeAllNotifications(). Maybe I'm doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions