removeAllListeners
로 제거하는 동작을 beforeEach에 넣어줌example
beforeEach(() => {
rendererEmt.removeAllListeners();
render(<MainScreen />);
});
describe('App bar', () => {
test('Exist AppBar', () => {
expect(screen.getByTestId('AppBar')).toBeTruthy();
});
});
describe('Spinner', () => {
test('Show spinner', async () => {
act(() => {
rendererEmt.emit('set-spinner', true);
});
expect(screen.getByTestId('spinner')).toBeInTheDocument();
});
test('hide spinner', async () => {
act(() => {
rendererEmt.emit('set-spinner', false);
});
await waitFor(() =>
expect(screen.queryByTestId('spinner')).not.toBeInTheDocument()
);
});
});