Jest + Puppeteer end to end test strange problem

Viewed 52

I am trying to make an e2e test for user to register new account and delete it afterwards. Everything works as expected. Puppeteer creates an account and deletes it successfully, but one of the tests show up as failed in the end without any data about it. Here is the screenshot of the test result.

jest-puppeteer-test-result

As you can see all the tests are dependent on the previous test to complete user registration and deleting the account afterwards.

It shows that 'click to settings link' test has failed. But in reality it hasnt failed. Its not possible to successfully complete the following tests, if that one was failed.

If I skip that test the following tests all fail.

This is the test that show as failed

  test('click to settings link', async () => {
    const linkSelector = '#navbar-link-settings';
    await page.waitForSelector(linkSelector);

    await page.click(linkSelector);
    await expect(page).toMatch('Account');
  });

And I did try it with a different logic which also failed:


  test('click to settings link', async () => {
    const linkSelector = '#navbar-link-settings';
    await page.waitForSelector(linkSelector);

    await expect(page).toClick(linkSelector);
  });
1 Answers

I did run the test with HEADLESS=false mode and noticed an error log on the browser console. When I fixed it the problem solved.

Edit: The issue is that because there was an error with some React component Pupeteer was showing successful test as failed. When I fixed the problem with the React test run succeeded.

Related