'How to trigger functions with wrapped mounted components JEST

So I am trying to add unit tests to my FUNCTIONAL components.

I am using react-redux + redux-saga in my application.

Component That I want to test:

enter image description here

This is the test that I have it right now

    const store = mockStore(state);

    wrapper = mount(
       <Provider store={ store }>
          <ItemTab />
       </Provider>
    );

In my component ItemTab.js I have this function

    function test() {
       console.log('testing')
    }

And in my ItemTab.test.js I am calling this test

describe('ItemTab', () => {
    it('first test', () => {
        wrapper.test()
    });
})

And If I do that I have this error wrapper.test is not a function

Notes:

  1. I tried using the dive() property but it doesn't seem to be working from me.
  2. I can't use shallow instead but the wrapper.instance() is always giving me null

So my questions are:

  1. How can I test a functional component with redux + redux-saga?
  2. How can I trigger a function inside a component without trying to find a button so I can trigger a simulation?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source