alexneo2003 / playwright-azure-reporter

Playwright Azure DevOps Reporter
MIT License
67 stars 11 forks source link

SyntaxError: Unexpected token 'R', "Request ti"... is not valid JSON #62

Closed kovacsdongo closed 6 months ago

kovacsdongo commented 6 months ago

when i want to run i get an error:

azure: Failed to create test run. Reporting is disabled. undefined:1 Request timeout: /avanderonline/_apis/Location ^

SyntaxError: Unexpected token 'R', "Request ti"... is not valid JSON at JSON.parse () at AzureDevOpsReporter.onBegin (C:\git\hydro-test\node_modules\@alex_neo\playwright-azure-reporter\src\playwright-azure-reporter.ts:290:34) at processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.11.1

alexneo2003 commented 6 months ago

Hi @kovacsdongo Can you read #15 maybe you find some helpful and after check your config and come back

daniavander commented 6 months ago

i don not know what was happened because it is worked: image

and also worked some 20 mins ago:

azure: Uploading attachments for test: [43193] IFE - Classify IFE handling
azure: Uploaded attachments
azure: Result published: [43193] IFE - Classify IFE handling
azure: Run 1001479 - Completed

but now i get this error

1 [regression] › tests\hydro\regression\caseEntities.spec.ts:438:8 › Reg desktop › [43193] IFE - Classify IFE handling
azure: Failed to create test run. Reporting is disabled.
undefined:1
Request timeout: /avanderonline/_apis/Location
^

SyntaxError: Unexpected token 'R', "Request ti"... is not valid JSON
    at JSON.parse (<anonymous>)
    at AzureDevOpsReporter.onBegin (C:\git\hydro-test\node_modules\@alex_neo\playwright-azure-reporter\src\playwright-azure-reporter.ts:290:34)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v20.11.1

my config

import { AzureReporterOptions } from '@alex_neo/playwright-azure-reporter/dist/playwright-azure-reporter';
[
      '@alex_neo/playwright-azure-reporter',
      {
        orgUrl: 'https://dev.azure.com/nsme/',
        token: 't4g2rfgf..',
        planId: 40947,
        projectName: "Sapa - IMS",
        environment: 'TAQA',
        logging: true,
        testRunTitle: 'Auto Test Run',
        publishTestResultsMode: 'testRun',
        uploadAttachments: true,
        attachmentsType: ['screenshot', 'trace'],
        isDisabled: false,
        testRunConfig: {
          owner: {
            displayName: 'KD',
          },
          comment: 'Playwright Test Run',
        },
      } as AzureReporterOptions
    ]

what is the problem?

daniavander commented 6 months ago

thanks the bug label :)

alexneo2003 commented 6 months ago

ok, first of all I checked my local run and it's successfull

Monosnap totalValuesVerification spec ts — V360-Automation 2024-03-27 11-33-07

@kovacsdongo @daniavander

  1. is your run local or on CI?
  2. can you change some code of reporter to help me with debug) file - node_modules/@alex_neo/playwright-azure-reporter/dist/playwright-azure-reporter.js line - 208 just log error message and show it for me
        catch (error) {
    +          console.log('🚀 ~ error:', error)
            this._isDisabled = true;
            if (error.message.includes('401')) {
                this._warning('Failed to create test run. Check your token. Reporting is disabled.');
            }
            else if (error.message.includes('getaddrinfo ENOTFOUND')) {
                this._warning('Failed to create test run. Check your orgUrl. Reporting is disabled.');
            }
            else {
                this._warning('Failed to create test run. Reporting is disabled.');
                const parsedError = JSON.parse(String(error.message.trim()));
                this._warning(parsedError?.message || error.message);
            }
        }
daniavander commented 6 months ago

@alexneo2003 now i want to run only local it it is going to work alltime i will take a step to cicd:D

here is the log

🚀 ~ error: Error: Request timeout: /avanderonline/_apis/Location
    at ClientRequest.<anonymous> (C:\git\hydro-test\node_modules\typed-rest-client\HttpClient.js:325:26)
    at Object.onceWrapper (node:events:632:28)
    at ClientRequest.emit (node:events:518:28)
    at TLSSocket.emitRequestTimeout (node:_http_client:840:9)
    at Object.onceWrapper (node:events:632:28)
    at TLSSocket.emit (node:events:530:35)
    at TLSSocket.Socket._onTimeout (node:net:589:8)
    at listOnTimeout (node:internal/timers:573:17)
    at processTimers (node:internal/timers:514:7)
azure: Failed to create test run. Reporting is disabled.
alexneo2003 commented 6 months ago

it's looks like some issues with Azure API I checked Azure status page and unfortunately don't see any issues unfortunately it's not reporter issue I'm already working on fix to improve errors logging I leave this issue opened and waiting maybe it will be fixed themself

daniavander commented 6 months ago

it's possible that the azure load is high, because yesterday afternoon it went fine several times is effective

alexneo2003 commented 6 months ago

@kovacsdongo @daniavander any updates?

daniavander commented 6 months ago

it is working now, perhaps it was an azure issue thnaks the help