Jest worker encountered 4 child process exceptions, exceeding retry limit

I had experienced this as well, and this issue thread led me in the right direction. Two things to try:

  1. You could try adding the --maxWorkers 2 to your jest test command.

  2. This error seems to be a mix of a few problems, but uncaught promise rejections are a player. You could also try using waitFor and see if this helps.

    import { waitFor } from 'test/test-utils'
    
    test("signupAsUser logs results if email is provided", async() => {
      const consoleSpy = jest.spyOn(console, "log");
      const email = ref("testuser@scoutapm.com");
      const {
        signupAsUser
      } = useSignup(email);
    
      await waitFor(() => signupAsUser());
    
      expect(consoleSpy).toHaveBeenCalledWith("USER:", mockSignup);
    });
    
  3. This answer shed more light.

    Digging deeper, this is because findBy tests return a promise so the await is needed. https://testing-library.com/docs/guide-disappearance/#1-using-findby-queries
    It would have been nice for the library to throw a better error however.

Leave a Comment