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

Running tests with the agent and sending logs sometimes fail on beforeAll #146

Open
aviadhadidainx opened this issue Jul 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@aviadhadidainx
Copy link

Hi.

We have been using the new capablity of sending attachment and also to send logs.
reportingApiInstance.attachment(null, ${message});

We are seeing an issue that sometimes when we run all tests the beforeAll try to send logs (This is related to our platform that the before all actually using method that send logs on underlying services)

Initially we tried to avoid it using this code:

      if (reportingApiInstance.reporter.tempStepId)
        await reportingApiInstance.attachment(null, `${message}`);
      } else {
        console.log(message);
      }

Because we are seeing that sometimes the tempId is still on the previous tests that was running and not cleaned we get this error:

Error: Item with tempId "16vpr4blypmr8wx" not found
12:19:02      at RPClient.sendLogWithoutFile (/automation/node_modules/@reportportal/client-javascript/lib/report-portal-client.js:709:9)
12:19:02      at RPClient.sendLog (/automation/node_modules/@reportportal/client-javascript/lib/report-portal-client.js:689:17)
12:19:02      at JestReportPortal.sendLog (/automation/node_modules/@reportportal/agent-js-jest/src/reporter.js:242:37)
12:19:02      at ReportingApi.attachment (/automation/node_modules/@reportportal/agent-js-jest/src/reportingApi.js:37:19)
12:19:02      at Function.attachment [as logApiToReports] (/automation/test/utils/LoggerUtils.js:12:36)
12:19:02      at Function.logApiToReports [as logHttpCall] (/automation/src/utils/ApiWrapperUtils.js:64:23)
12:19:02      at Function.logHttpCall (/automation/src/utils/ApiWrapperUtils.js:44:29)
12:19:02      at processTicksAndRejections (node:internal/process/task_queues:95:5)

To overcome for now we have looked into the lib and did the following:

 if (reportingApiInstance.reporter.client.map[tempStepId]) {
        await reportingApiInstance.attachment(null, `${message}`);
      } else {
        console.log(message);
      }

I think there is a bug cleaning up the tempId and if not maybe add config flag not to fail the run on this code that run at the end of the test suites
image

NOTE: We are running tests in band, and i couldn't reproduce easily.. Happens on several tests with the beforeAll API calls

@AmsterGet
Copy link
Member

Hi @aviadhadidainx !
Thanks for your investigations and workaround!
I'll try to dive into this as soon as I get a chance and will keep you posted.

@AmsterGet AmsterGet self-assigned this Jul 18, 2024
@AmsterGet AmsterGet added the bug Something isn't working label Jul 18, 2024
@roboalex2
Copy link

I have the same issue how can i get an instance of reportingApiInstance.reporter? agent-js-jest does not offer me ReportingApi and agent-js-playwright does offer me ReportingApi but not ReportingApi.attachment;

@aviadhadidainx
Copy link
Author

@roboalex2 You can get it like that - global.ReportingApi

It will be exist if you are in the context of jest running tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants