Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda