I have following codes, trying to test fireevent onclick but it responds an error. What is the problem?
test('fires onClick event', ()=>{
const onClick= jest.fn();
const {getByTestId}=render(<App></App>)
fireEvent.click(getByTestId('add-board'));
expect(onClick).toHaveBeenCalled();
})
ERROR:
● fires onClick event
expect(jest.fn()).toHaveBeenCalled()
Expected number of calls: >= 1
Received number of calls: 0
43 | const {getByTestId}=render(<App></App>)
44 | fireEvent.click(getByTestId('add-board'));
> 45 | expect(onClick).toHaveBeenCalled();
| ^
46 |
47 | })
48 |
at Object.<anonymous>.test (src/App.test.js:45:26)