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

151
Visualizações
What does the error "function must be overridden" mean in jest?

I'm new to testing and jest. I'm using it together with react testing library to test a react application.

Particularly, I'm trying to test a header button that is responsible for changing the language of the website. As I understand so far, it's better to test for the "results" of the action (the text in the desired language rendered on the screen) rather than for the "logic" (the state of the app changing), so that's what I'm trying to do.

The actual test is the following:

test('Changes language on click', () => {
  render( <BrowserRouter> <Header /> </BrowserRouter> )
  
  userEvent.click(screen.getByTestId('es-language-btn'))
  expect(screen.getByTestId('about-desktop-btn')).toHaveTextContent('Sobre mi')
})

And the error I'm getting is this:

setEnglishLanguage function must be overridden

      12 |     setDarkModeOn: (): void => {throw new Error('setDarkModeOn function must be overridden')},
      13 |     englishLanguage: false,
    > 14 |     setEnglishLanguage: (): void => {throw new Error('setEnglishLanguage function must be overridden')}
         |                                            ^
      15 | }
      16 |
      17 | const Context = createContext <ContextInterface>(defaultState)

setEnglishLanguage is the function responsible of the state change the button triggers, but I don't know what overriding it means or how should I do it.

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