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

159
Views
Testing React/Jest component with Window.onload

I'm testing a functional component that uses Window.onload to stay on a certain page. Example of the code

function SignUpForm(props) {

  const history = useHistory();
  const {setOnPage } = props;
  window.onload = setOnPage("/registrarse")

My test is:

import React from 'react'
import Enzyme from "enzyme";
import { screen, render } from '@testing-library/react'

import SignInScreen from './SignInScreen'
import Adapter from "enzyme-adapter-react-16"

const { shallow } = Enzyme; 

Enzyme.configure({ adapter: new Adapter() })

describe('Test for login in form', () => {
    test("renders correctly", () => {
        shallow(<SignInScreen/>);
      });
});

The error is in the line of Window.onload, I have not been able to find any solution that can help me.

setOnPage is not a function
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!