Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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?
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda