Skip to content

Commit

Permalink
Merge pull request #39 from joerg1985/extended-state
Browse files Browse the repository at this point in the history
report different states to azure test plans
  • Loading branch information
alexneo2003 authored Aug 16, 2023
2 parents 02c70b0 + 1042c5d commit 0e7bad5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [1.6.0](https://github.com/alexneo2003/playwright-azure-reporter/compare/v1.6.0-beta.1...v1.6.0) (2023-08-16)



# [1.6.0-beta.1](https://github.com/alexneo2003/playwright-azure-reporter/compare/v1.6.0-beta.0...v1.6.0-beta.1) (2023-08-11)



# [1.6.0-beta.0](https://github.com/alexneo2003/playwright-azure-reporter/compare/v1.5.8...v1.6.0-beta.0) (2023-08-09)



## [1.5.8](https://github.com/alexneo2003/playwright-azure-reporter/compare/v1.5.8-beta.2...v1.5.8) (2023-07-05)


Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alex_neo/playwright-azure-reporter",
"version": "1.5.8",
"version": "1.6.0",
"description": "Playwright Azure Reporter",
"main": "./dist/playwright-azure-reporter.js",
"types": "./dist/playwright-azure-reporter.d.js",
Expand Down Expand Up @@ -40,7 +40,6 @@
"dependencies": {
"azure-devops-node-api": "^12.0.0",
"chalk": "4.1.2",
"colors": "^1.4.0",
"debug": "^4.3.4",
"mime": "^3.0.0"
},
Expand Down
29 changes: 24 additions & 5 deletions src/playwright-azure-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ import { existsSync, readFileSync } from 'fs';
import debug from './debug';
import { createGuid, getExtensionFromContentType, getExtensionFromFilename, shortID } from './utils';

// https://learn.microsoft.com/en-us/azure/devops/report/analytics/entity-reference-test-plans?view=azure-devops#testoutcome-enumerated-type-members
enum EAzureTestStatuses {
passed = 'Passed',
failed = 'Failed',
skipped = 'Paused',
timedOut = 'Failed',
interrupted = 'Failed',
fixme = 'Paused',
skipped = 'NotApplicable',
other = 'Blocked',
timedOut = 'Timeout',
interrupted = 'Aborted',
}

const attachmentTypesArray = ['screenshot', 'video', 'trace'] as const;
Expand Down Expand Up @@ -589,6 +592,22 @@ class AzureDevOpsReporter implements Reporter {
return attachmentsResult;
}

private _mapToAzureState(test: TestCase, testResult: TestResult): string {
let status = testResult.status;

if (status == 'skipped') {
if (test.annotations.findIndex((e) => e.type === 'fixme') != -1) {
return EAzureTestStatuses['fixme'];
} else if (test.annotations.findIndex((e) => e.type === 'skip') != -1) {
return EAzureTestStatuses['skipped'];
} else {
return EAzureTestStatuses['other'];
}
} else {
return EAzureTestStatuses[status];
}
}

private async _publishCaseResult(test: TestCase, testResult: TestResult): Promise<TestResultsToTestRun | void> {
const caseIds = this._getCaseIds(test);
if (!caseIds || !caseIds.length) return;
Expand Down Expand Up @@ -620,7 +639,7 @@ class AzureDevOpsReporter implements Reporter {
({
// the testPoint is the testCase + configuration, there is not need to set these
testPoint: { id: String(testPoint.id) },
outcome: EAzureTestStatuses[testResult.status],
outcome: this._mapToAzureState(test, testResult),
state: 'Completed',
durationInMs: testResult.duration,
errorMessage: testResult.error
Expand Down Expand Up @@ -683,7 +702,7 @@ class AzureDevOpsReporter implements Reporter {
...testPoints.map((testPoint) => ({
// the testPoint is the testCase + configuration, there is not need to set these
testPoint: { id: String(testPoint.id) },
outcome: EAzureTestStatuses[testResult.status],
outcome: this._mapToAzureState(testCase, testResult),
state: 'Completed',
durationInMs: testResult.duration,
errorMessage: testResult.error
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,6 @@ colors@0.6.x:
resolved "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz"
integrity sha512-OsSVtHK8Ir8r3+Fxw/b4jS1ZLPXkV6ZxDRJQzeD7qo0SqMXWrHDM71DgYzPMHY8SFJ0Ao+nNU2p1MmwdzKqPrw==

colors@^1.4.0:
version "1.4.0"
resolved "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz"
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==

colors@~1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz"
Expand Down

0 comments on commit 0e7bad5

Please sign in to comment.