Skip to content

Commit

Permalink
feat: remove QaseID from test names in output
Browse files Browse the repository at this point in the history
When specifying test names, QaseIDs are now excluded from the final test name. For example, `Example (Qase ID: 1)` will appear as `Example` in the test output.
  • Loading branch information
gibiw committed Nov 8, 2024
1 parent 99eb31f commit e524088
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
14 changes: 14 additions & 0 deletions qase-cypress/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [email protected]

## What's new

When specifying test names, QaseIDs are now excluded from the final test name.

```js
// The test name will be 'Example', not 'Example (Qase ID: 1)'
qase(1,it('Example', () => {
expect(true).to.equal(true);
})
);
```

# [email protected]

## What's new
Expand Down
4 changes: 2 additions & 2 deletions qase-cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-qase-reporter",
"version": "2.2.0",
"version": "2.2.1",
"description": "Qase Cypress Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"sideEffects": false,
Expand Down Expand Up @@ -47,7 +47,7 @@
"author": "Qase Team <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"qase-javascript-commons": "~2.2.0",
"qase-javascript-commons": "~2.2.3",
"uuid": "^9.0.1"
},
"peerDependencies": {
Expand Down
15 changes: 14 additions & 1 deletion qase-cypress/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class CypressQaseReporter extends reporters.Base {
thread: null,
},
testops_id: ids.length > 0 ? ids : null,
title: metadata?.title ?? test.title,
title: metadata?.title ?? this.removeQaseIdsFromTitle(test.title),
};

void this.reporter.addTestResult(result);
Expand Down Expand Up @@ -302,6 +302,19 @@ export class CypressQaseReporter extends reporters.Base {
return undefined;
}

/**
* @param {string} title
* @returns {string}
* @private
*/
private removeQaseIdsFromTitle(title: string): string {
const matches = title.match(/\(Qase ID: ([0-9,]+)\)$/i);
if (matches) {
return title.replace(matches[0], '').trimEnd();
}
return title;
}

private getSteps(steps: (StepStart | StepEnd)[], attachments: Record<string, Attachment[]>): TestStepType[] {
const result: TestStepType[] = [];
const stepMap = new Map<string, TestStepType>();
Expand Down

0 comments on commit e524088

Please sign in to comment.