estruyf / playwright-github-actions-reporter

GitHub Actions reporter for Playwright
https://www.npmjs.com/package/@estruyf/github-actions-reporter
MIT License
40 stars 2 forks source link

Error in reporter TypeError: Cannot read properties of undefined (reading 'status') #6

Closed Silvest89 closed 8 months ago

Silvest89 commented 8 months ago
Using GitHub Actions reporter
Error in reporter TypeError: Cannot read properties of undefined (reading 'status')
    at /__w/frontend/frontend/node_modules/@estruyf/github-actions-reporter/dist/utils/getTotalStatus.js:13:31
    at Array.map (<anonymous>)
    at getTotalStatus (/__w/frontend/frontend/node_modules/@estruyf/github-actions-reporter/dist/utils/getTotalStatus.js:[11](https://github.com/shiftbase-com/frontend/actions/runs/7969533734/job/21755504131#step:5:12):46)
    at GitHubAction.<anonymous> (/__w/frontend/frontend/node_modules/@estruyf/github-actions-reporter/dist/index.js:71:73)
    at Generator.next (<anonymous>)

This is what happens when your tests are depending on other tests. (eg other tests are not run which means 0 results)

estruyf commented 8 months ago

Hi @Silvest89,

Can you reproduce this in a simple test case?

I've tried to do it as follows:

import { test, Page } from "@playwright/test";

test.describe.serial("Timeout test", () => {
  let page: Page;

  test.setTimeout(2000);

  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();

    await page.goto("https://www.google.com/", {
      waitUntil: "domcontentloaded",
    });
  });

  test.afterAll(async ({ browser }) => {
    await page.close();
    await browser.close();
  });

  test("Fake timeout 1", async () => {
    await page.waitForTimeout(100);
    throw new Error("Fake error");
  });

  test("Fake timeout 2", async () => {
    await page.waitForTimeout(3000);
  });

  test("Fake timeout 3", async () => {
    await page.waitForTimeout(3000);
  });
});

But the above doesn't trigger your test case.

Silvest89 commented 8 months ago

@estruyf Let me give you an example

When using this setup with dependencies in playwright.config,

    {
      name: 'setup',
    },
    {
      name: 'tests',
      dependencies: ['setup'],
    },

Lets say I have this test in the setup folder

test.describe.serial("Setup", () => {
  let page: Page;

  test.setTimeout(5000);
  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();

    await page.goto("https://www.google.com/", {
      waitUntil: "domcontentloaded",
    });
  });
  test("Fake timeout 1", async () => {
    await page.waitForURL('ssss');
  });
});

Which is bound to fail. Other tests which have setup as dependency will have a results array with 0 results

image

estruyf commented 8 months ago

Thanks! I've been able to reproduce it, and it seems it is related to some changes in the new version of Playwright Testing. In earlier versions, those tests were returned with a status of skipped.

estruyf commented 8 months ago

Can you try out if version @estruyf/github-actions-reporter@1.5.0-beta.7972167 fixes your issue?

Silvest89 commented 8 months ago

Works fine now! Thanks :)

estruyf commented 8 months ago

Thanks!