cypress-aiotests-reporter
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -11,7 +11,14 @@ describe('empty spec ', () => { | ||
it('NVTES-TC-5, NVTES-TC-6 : displays two todo items by default', () => { | ||
it('NVTES-TC-5 : displays two todo items by default', () => { | ||
cy.get('.todo-list li').should('have.length', 2) | ||
cy.wait(2000); | ||
cy.get('.todo-list li').first().should('have.text', 'Pay electric bill') | ||
cy.get('.todo-list li').last().should('have.text', 'Walk the dog') | ||
}) | ||
it(' NVTES-TC-6 : displays two todo items by default failure', () => { | ||
cy.get('.todo-list li').should('have.length', 2) | ||
cy.get('.todo-list li').first().should('have.text', 'Pay electric bills') | ||
cy.get('.todo-list li').last().should('have.text', 'Walk the dog') | ||
}) | ||
}) |
{ | ||
"name": "cypress-aiotests-reporter", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Plugin to report cypress results to AIO Tests Jira", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -14,3 +14,3 @@ [](https://github.com/aiotests/cypress-aiotests-reporter/actions/workflows/main.yml) | ||
> Please note that with Cypress 13, Cypress has made breaking changes to its module API which used to expose data on results of executions. | ||
> Due to this change, AIO Tests reporter can no longer send screenshots and body information to AIO Tests. | ||
> Due to this change, AIO Tests reporter can no longer send body information and retry durations to AIO Tests. | ||
> If you would like to have this feature, please bump up the request @ [Cypress 13 Module API bug](https://github.com/cypress-io/cypress/issues/27732) | ||
@@ -165,15 +165,15 @@ # How to get started? | ||
| Value | Description | | ||
|-----------------------------|---------------------------------------------------------------------------------------------------| | ||
| enableReporting | Set to true to make the current run update results to AIO Tests. Default false. | | ||
| jiraProjectId | Jira Project key to update results to | | ||
| cycleDetails.createNewCycle | Set to true to create a new cycle for run being reported | | ||
| cycleDetails.cycleName | Works if createNewCycle is true, sets the cycle name of cycle getting created | | ||
| cycleDetails.cycleKey | AIO Tests cycle key that should be updated. Used if createNewCycle is false | | ||
| cycleDetails.folder | Folder hierarchy, where first item in array is parent folder and so on eg.["Parent","Child"] | | ||
| cycleDetails.tasks | List of Jira Issue Keys to attach as Tasks to created cycle, impacts only when creating new cycle | | ||
| addNewRun | Create a new run or update an existing run in the cycle | | ||
| addAttachmentToFailedCases | Set to true to attach screenshots, if available, for failed cases | | ||
| createNewRunForRetries | Set to true if each retry should create a new run | | ||
| addTestBodyToComments | Set to true test script body should be added as a comment in a failed case | | ||
| Value | Description | | ||
|-----------------------------|------------------------------------------------------------------------------------------------------| | ||
| enableReporting | Set to true to make the current run update results to AIO Tests. Default false. | | ||
| jiraProjectId | Jira Project key to update results to | | ||
| cycleDetails.createNewCycle | Set to true to create a new cycle for run being reported | | ||
| cycleDetails.cycleName | Works if createNewCycle is true, sets the cycle name of cycle getting created | | ||
| cycleDetails.cycleKey | AIO Tests cycle key that should be updated. Used if createNewCycle is false | | ||
| cycleDetails.folder | Folder hierarchy, where first item in array is parent folder and so on eg.["Parent","Child"] | | ||
| cycleDetails.tasks | List of Jira Issue Keys to attach as Tasks to created cycle, impacts only when creating new cycle | | ||
| addNewRun | Create a new run or update an existing run in the cycle | | ||
| addAttachmentToFailedCases | Set to true to attach screenshots, if available, for failed cases | | ||
| createNewRunForRetries | Set to true if each retry should create a new run | | ||
| addTestBodyToComments | Set to true test script body should be added as a comment in a failed case. Doesn't work above v12.x | | ||
@@ -180,0 +180,0 @@ |
@@ -74,3 +74,3 @@ const axios = require('axios'); | ||
let attemptData = testData.get(ck).attempts; | ||
if(attemptData.length == 1 && attemptData[0].state !== "failed") { | ||
if(attemptData.length === 1 && attemptData[0].state !== "failed") { | ||
passedCaseKeys.push(ck); | ||
@@ -106,3 +106,3 @@ } else { | ||
return resolve.then(() => { | ||
return postResult(config, key, attempt, caseData.id + "_" + (idx++) ,screenshots,caseData.body) | ||
return postResult(config, key, attempt, caseData ,screenshots, idx++) | ||
}); | ||
@@ -114,6 +114,6 @@ }, Promise.resolve()).catch(e => { | ||
function postResult(aioConfig,caseKey, attemptData, id, screenshots, body, trialCounter = 0 ) { | ||
function postResult(aioConfig,caseKey, attemptData, caseData, screenshots, attemptNumber, trialCounter = 0 ) { | ||
let data = { | ||
"testRunStatus": getAIORunStatus(attemptData.state), | ||
"effort": attemptData.wallClockDuration/1000, | ||
"effort": (attemptData.wallClockDuration? attemptData.wallClockDuration : (caseData.attempts.length === attemptNumber + 1? caseData.duration : 0))/1000, | ||
"isAutomated": true | ||
@@ -124,6 +124,6 @@ }; | ||
if(!!aioConfig.addTestBodyToComments) { | ||
data["comments"].push("Test Body : " + body); | ||
data["comments"].push("Test Body : " + caseData.body); | ||
} | ||
} | ||
let createNewRun = id.endsWith("_0") ? !!aioConfig.addNewRun : !!aioConfig.createNewRunForRetries; | ||
let createNewRun = attemptNumber === 0 ? !!aioConfig.addNewRun : !!aioConfig.createNewRunForRetries; | ||
return aioAPIClient | ||
@@ -135,3 +135,3 @@ .post(`/project/${aioConfig.jiraProjectId}/testcycle/${aioConfig.cycleDetails.cycleKeyToReportTo}/testcase/${caseKey}/testrun?createNewRun=${createNewRun}`, data) | ||
if(aioConfig.addAttachmentToFailedCases && data.testRunStatus.toLowerCase() === "failed" && (isAttachmentAPIAvailable || isAttachmentAPIAvailable == null)) { | ||
return uploadAttachments(aioConfig.jiraProjectId, aioConfig.cycleDetails.cycleKeyToReportTo, runId,id, screenshots) | ||
return uploadAttachments(caseKey, aioConfig.jiraProjectId, aioConfig.cycleDetails.cycleKeyToReportTo, runId,caseData.id, screenshots, attemptNumber) | ||
} | ||
@@ -144,3 +144,3 @@ }) | ||
await sleep(rateLimitWaitTime); | ||
return postResult(aioConfig, caseKey, attemptData, id, screenshots, body, trialCounter++); | ||
return postResult(aioConfig, caseKey, attemptData, caseData, screenshots, attemptNumber, trialCounter++); | ||
} else { | ||
@@ -163,3 +163,3 @@ aioLogger.error("Error reporting " + caseKey + " : Status Code - " + err.response.status + " - " + err.response.data); | ||
"testRunStatus": getAIORunStatus(attemptData.state), | ||
"effort": attemptData.wallClockDuration/1000, | ||
"effort": (attemptData.wallClockDuration? attemptData.wallClockDuration : testData.get(passedCaseKey).duration)/1000, | ||
"isAutomated": true | ||
@@ -195,4 +195,7 @@ }); | ||
function uploadAttachments(jiraProjectId, cyclekey,runId, id, resultScreenshots) { | ||
let screenshots = resultScreenshots.filter(t => (t.testId + "_" + t.testAttemptIndex) === id); | ||
function uploadAttachments(caseKey, jiraProjectId, cyclekey,runId, id, resultScreenshots, attemptNumber) { | ||
let screenshots = resultScreenshots.filter(t => (t.testId + "_" + t.testAttemptIndex) === (id +"_"+attemptNumber)); | ||
if(resultScreenshots && !resultScreenshots[0].testId) { | ||
screenshots = resultScreenshots.filter(t => t.path.includes(caseKey) && (t.path.includes("attempt "+ (attemptNumber +1)) || (attemptNumber === 0 && !t.path.includes("(attempt ")))); | ||
} | ||
if(screenshots.length) { | ||
@@ -247,3 +250,3 @@ return screenshots.reduce((r,screenshot) => { | ||
if(tcKeys.length) { | ||
tcKeys.forEach(tcKey => testData.set(tcKey, {attempts: t.attempts, id : t.testId, body: t.body})) | ||
tcKeys.forEach(tcKey => testData.set(tcKey, {attempts: t.attempts, id : t.testId, body: t.body, duration: t.duration})) | ||
} | ||
@@ -250,0 +253,0 @@ }); |
Sorry, the diff of this file is not supported yet
480767
20
512