Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!