Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent fails on this.findTestItem(this.testItems, test.title, playwrightProjectName).id; #45

Closed
MichalFidor opened this issue Apr 20, 2022 · 4 comments
Assignees

Comments

@MichalFidor
Copy link

Hi guys. I'm using in repo @playwright/test version 1.20 and agent in version 5.0.3 and when I enabled the option with includeTestSteps, then at beginning of the test run it throw an error:

Error in reporter TypeError: Cannot read property 'id' of undefined in .../node_modules/@reportportal/agent-js-playwright/src/reporter.ts:411

When I console.logged this line of code, then it looks like not always this method returns the step. But I've added a check - basic if:
if (this.findTestItem(this.nestedSteps, step.title, playwrightProjectName)) for method onStepEnd and it started to work. Steps are properly attached to report. But still there is a similar error in onStepBegin:

Error in reporter TypeError: Cannot read property 'id' of undefined at RPReporter.onStepBegin (.../node_modules/@reportportal/agent-js-playwright/src/reporter.ts:391:100)
together with error:
Failed to start nested step. Error: timeout of 30000ms exceeded at .../node_modules/@reportportal/client-javascript/lib/rest.js:37:15

Not sure how to solve it...

@AmsterGet
Copy link
Member

@oranje322 Could you please check the issue above?

@artemrudenko
Copy link
Contributor

artemrudenko commented Apr 21, 2022

Hi, I have also discovered this issue, it fails in beforeAll for my case.

The failing line is ( https://github.com/reportportal/agent-js-playwright/blob/master/src/reporter.ts#L391 ):
const { id: testItemId } = this.findTestItem(this.testItems, test.title, playwrightProjectName);

Since it's ok when item not found( see https://github.com/reportportal/client-javascript/blob/master/lib/report-portal-client.js#L400 ) i fixed this as:


  onStepBegin(test: TestCase, result: TestResult, step: TestStep): void {
    if (!this.includeTestSteps) return;
    const playwrightProjectName = RPReporter.getTestProjectName(test);
    const testItem = this.findTestItem(this.testItems, test.title, playwrightProjectName);
    const stepStartObj = {
      name: step.title,
      type: TEST_ITEM_TYPES.STEP,
      hasStats: false,
      startTime: this.client.helpers.now(),
    };

    const { tempId, promise } = this.client.startTestItem(
      stepStartObj,
      this.launchId,
      testItem?.id,
    );

    this.addRequestToPromisesQueue(promise, 'Failed to start nested step.');
    this.nestedSteps.set(tempId, {
      name: step.title,
      id: tempId,
      playwrightProjectName,
    });
  }

  onStepEnd(test: TestCase, result: TestResult, step: TestStep): void {
    if (!this.includeTestSteps) return;
    const playwrightProjectName = RPReporter.getTestProjectName(test);
    const testItem = this.findTestItem(this.nestedSteps, step.title, playwrightProjectName);
    if (testItem?.id) {
      const stepFinishObj = {
        status: step.error ? STATUSES.FAILED : STATUSES.PASSED,
        endTime: this.client.helpers.now(),
      };

      const { promise } = this.client.finishTestItem(testItem?.id, stepFinishObj);

      this.addRequestToPromisesQueue(promise, 'Failed to finish nested step.');
      this.nestedSteps.delete(testItem?.id);
    }
  }

Best Regards,
Artem

@renkyoji
Copy link
Contributor

Hello,
This bug started appearing in @playwright/test version 1.18 and higher.
You can temporarily use @playwright/test version 1.17

The bug will be fixed in the next version agent.

@renkyoji
Copy link
Contributor

The fix was released in version 5.0.4 #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants