title: jest puppeteer how to use setTimeout
body: <p>I am a newbie at running Jest puppeteer.</p>
  <p>I'm trying to run a test suite locally that I did not write.</p>
  <p>All the tests fail to run and I get this error pointing at beforeEach...</p>
  <p>&quot;beforeEach(async () =&gt; {&quot;</p>
  <p>&quot;thrown: &quot;Exceeded timeout of 5000 ms for a hook.
  Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test.&quot;&quot;</p>
  <p>Where / how exactly should I place the setTimeout?</p>
  <p>Is there something else I am missing or have in the wrong spot?</p>
  <pre><code>
  const baseURL = &quot;http://localhost:1234&quot;;
  const puppeteer = require('puppeteer');
  
  beforeEach(() =&gt; {
    // Reset mock function's states before each test.
    jest.clearAllMocks();
  });
  
  
  describe(&quot;chatbot&quot;, () =&gt; {
    beforeEach(async () =&gt; {
      const browser = await puppeteer.launch({headless: false, slowMo: 250,});
      const page = await browser.newPage();
  
    
      await page.goto(baseURL, { waitUntil: &quot;load&quot; });
      // set the fade-ins to 0 ms to prevent timeouts in tests
      await page.evaluate(() =&gt; { window.animationDelay = 0 })
      await page.click(&quot;#chat-circle&quot;);
  
      await browser.close()
    });
  
  
  
    it(&quot;should show contact info when the user enters 'contact'&quot;, async () =&gt; {
      // submit the form with a message, expect to see the response
      const message = &quot;contact&quot;;
      await page.evaluate(() =&gt; {
        // get this same const in the page's context
        const message = &quot;contact&quot;;
        $(&quot;#chat-input&quot;).val(message)
      });
      await page.click(&quot;#chat-submit&quot;);
      await expect(page).toMatch(&quot;We have 24 hour phone support. Our phone number is +01 312 555 8432. We look forward to hearing from you!&quot;);
    });
  
    it(&quot;should show credit card help message when the user enters 'credit card'&quot;, async () =&gt; {
      // submit the form with a message, expect to see the response
      const message = &quot;credit card&quot;;
      await page.evaluate(() =&gt; {
        // get this same const in the page's context
        const message = &quot;credit card&quot;;
        $(&quot;#chat-input&quot;).val(message)
      });
      await page.click(&quot;#chat-submit&quot;);
      await expect(page).toMatch(&quot;You can pay with any major credit card. Enter your card details and billing address at checkout.&quot;);
    });
  
    it(&quot;should show payment help message when the user enters 'payment'&quot;, async () =&gt; {
      // submit the form with a message, expect to see the response
      const message = &quot;payment&quot;;
      await page.evaluate(() =&gt; {
        // get this same const in the page's context
        const message = &quot;payment&quot;;
        $(&quot;#chat-input&quot;).val(message)
      });
      await page.click(&quot;#chat-submit&quot;);
      await expect(page).toMatch(&quot;We have three payment options: credit card, paypal, or apple pay. Choose your preferred method at checkout.&quot;);
    });
  
    it(&quot;should show help options when the users enters 'help'&quot;, async () =&gt; {
      // submit the form with a message, expect to see the response
      const message = &quot;help&quot;;
      await page.evaluate(() =&gt; {
        // get this same const in the page's context
        const message = &quot;help&quot;;
        $(&quot;#chat-input&quot;).val(message)
      });
      await page.click(&quot;#chat-submit&quot;);
      await expect(page).toMatch(&quot;Enter a keyword for help with a topic: contact, payment, credit card, destinations.&quot;);
    });
  });
  
  </code></pre>
  <p>Thank you</p>