reportportal / agent-js-playwright

Agent to integrate Playwright with ReportPortal.
https://www.npmjs.com/package/@reportportal/agent-js-playwright
Apache License 2.0
34 stars 14 forks source link

Test is not finished when expect().toPass() exceed test timeout #111

Closed danielsobon closed 1 year ago

danielsobon commented 1 year ago

Test setup:

├── @playwright/test@1.35.1 ├── @reportportal/agent-js-playwright@5.1.2

How to reproduce

  1. Set up test timeout to 20 sec
    const config: PlaywrightTestConfig = {
    globalSetup: require.resolve('./global-setup'),
    /* Maximum time one test can run for. */
    timeout: 20 * 1000,
    }
  2. Create a test with any of repeatable check for 30 sec
    • expect.poll()
    • expect().toPass()
      
      import { expect, test } from '@playwright/test';

test.describe('Expect', () => { test(Expect pool @desktop, async () => { await expect .poll( () => { return 1; }, { timeout: 30_000 } ) .toBe(2); }); test('Expect toPass @desktop', async () => { await expect(() => { expect(1).toBe(2); }).toPass({ timeout: 30_000 }); }); });


4. Configure RP to `includeTestSteps: true`

###  Actual result
Test & test step (expect) are still in progress, so the entire run is also not finished
![image](https://github.com/reportportal/agent-js-playwright/assets/114917701/f7f91922-e535-41b6-aafd-96705d7a8e3f)
danielsobon commented 1 year ago

hey @AmsterGet, any update regarding the issue? I'm asking because we realized the problem is more serious than we thought. Because of fact the assertion cannot be finished we don't receive report, nor valid status of entire playwright run.

image

AmsterGet commented 1 year ago

Hey @danielsobon! Thanks for pointing this out! Our team has begun to investigate this issue. We will keep you updated on this thread.

Bam6ycha commented 1 year ago

Hey @danielsobon. This issue has been successfully fixed and will be available in the next version of the agent. But I have several questions. Why are you using timeout inside the test greater than your global timeout? Does your provided example only reproduce the bug, or is it the real case?

If it is only to reproduce, and you have such tests which run as long as the global timeout exceeds we recommend splitting it into small pieces and running them in parallel.

danielsobon commented 1 year ago

@Bam6ycha yep :) We have tests that consist of many steps. Each of them can take some time. In case of bad performance of application, all combined steps can reach the test timeout, so this is a real case.

Second thing, what you can also reproduce is, when we reach expect timeout during preforming operation, example API request. Example code (I recommend to set 2-3 retries because it might be reproduced in random run):

import test, { expect, request } from '@playwright/test';

test.describe('Expect @desktop @smoke', () => {
  test.only('Expect toPass @desktop @smoke', async () => {
    await expect(async () => {
      const status = await sendRequestStep();
      expect(status).toBe(400); //status returns 200
    }).toPass({ timeout: 5_000 });
  });
});

async function sendRequestStep() {
  return await test.step(`I get available pets status response`, async () => {
    const context = await request.newContext({
      baseURL: 'https://petstore.swagger.io',
    });
    const status = await context
      .get('/v2/pet/findByStatus?status=available', {})
      .then((response) => response.status())
      .finally(async () => await context.dispose());
    return status;
  });
}

RP view image

danielsobon commented 1 year ago

hey @AmsterGet do you know when I could expect new release?

AmsterGet commented 1 year ago

Hi @danielsobon ! I suppose in a few days. Stay tuned, we'll notify you here.

AmsterGet commented 1 year ago

Hi @danielsobon ! Please check the version 5.1.3.

danielsobon commented 1 year ago

@AmsterGet , @Bam6ycha I've already retested it. Problem does not occur anymore, thx for fix! 😎