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

feature: support QaseIgnore tag #689

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions qase-cucumberjs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# qase-cucumberjs@2.0.2

## What's new

- Support `QaseIgnore` tag. If the test case has the `QaseIgnore` tag, the reporter will not send the result to the Qase
TMS.

```cucumber
@QaseIgnore
Scenario: simple test
```

- Improved error handling.

# qase-cucumberjs@2.0.0

## What's new
Expand Down
2 changes: 1 addition & 1 deletion qase-cucumberjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cucumberjs-qase-reporter",
"version": "2.0.1",
"version": "2.0.2",
"description": "Qase TMS CucumberJS Reporter",
"homepage": "https://github.com/qase-tms/qase-javascript",
"main": "./dist/index.js",
Expand Down
8 changes: 4 additions & 4 deletions qase-cucumberjs/src/models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

interface TestMetadata {

Check warning on line 1 in qase-cucumberjs/src/models.ts

View workflow job for this annotation

GitHub Actions / Project qase-cucumberjs - Node 16

'TestMetadata' is defined but never used

Check warning on line 1 in qase-cucumberjs/src/models.ts

View workflow job for this annotation

GitHub Actions / Project qase-cucumberjs - Node 16

'TestMetadata' is defined but never used

Check warning on line 1 in qase-cucumberjs/src/models.ts

View workflow job for this annotation

GitHub Actions / Project qase-cucumberjs - Node 18

'TestMetadata' is defined but never used

Check warning on line 1 in qase-cucumberjs/src/models.ts

View workflow job for this annotation

GitHub Actions / Project qase-cucumberjs - Node 18

'TestMetadata' is defined but never used
ids : number[];
fields : Record<string, string>;
title : string | null;
ids: number[];
fields: Record<string, string>;
title: string | null;
isIgnore: boolean;
}
39 changes: 31 additions & 8 deletions qase-cucumberjs/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TestStepFinished,
} from '@cucumber/messages';
import {
Attachment,
Attachment, CompoundError,
Relation,
StepStatusEnum,
StepType,
Expand All @@ -26,6 +26,7 @@ const qaseIdRegExp = /^@[Qq]-?(\d+)$/g;
const newQaseIdRegExp = /^@[Qq]ase[Ii][Dd]=(\d+)$/g;
const qaseTitleRegExp = /^@[Qq]ase[Tt]itle=(.+)$/g;
const qaseFieldsRegExp = /^@[Qq]ase[Ff]ields:(.+?)=(.+)$/g;
const qaseIgnoreRegExp = /^@[Qq]ase[Ii][Gg][Nn][Oo][Rr][Ee]$/g;

export class Storage {
/**
Expand Down Expand Up @@ -195,11 +196,14 @@ export class Storage {
return undefined;
}

let error: Error | undefined;
const metadata = this.parseTags(pickle.tags);

if (this.testCaseStartedErrors[tcs.id]?.length) {
error = new Error(this.testCaseStartedErrors[tcs.id]?.join('\n\n'));
if (metadata.isIgnore) {
return undefined;
}

const error = this.getError(tcs.id);

let relations: Relation | null = null;
const nodeId = pickle.astNodeIds[pickle.astNodeIds.length - 1];
if (nodeId != undefined && this.scenarios[nodeId] != undefined) {
Expand All @@ -215,8 +219,6 @@ export class Storage {
};
}

const metadata = this.parseTags(pickle.tags);

return {
attachments: [],
author: null,
Expand All @@ -225,11 +227,11 @@ export class Storage {
start_time: null,
end_time: null,
duration: Math.abs(testCase.timestamp.seconds - tcs.timestamp.seconds),
stacktrace: error?.stack ?? null,
stacktrace: error?.stacktrace ?? null,
thread: null,
},
fields: metadata.fields,
message: null,
message: error?.message ?? null,
muted: false,
params: {},
group_params: {},
Expand Down Expand Up @@ -322,6 +324,7 @@ export class Storage {
ids: [],
fields: {},
title: null,
isIgnore: false,
};

for (const tag of tags) {
Expand Down Expand Up @@ -350,6 +353,10 @@ export class Storage {
// do nothing
}
}

if (qaseIgnoreRegExp.test(tag.name)) {
metadata.isIgnore = true;
}
}

return metadata;
Expand All @@ -371,4 +378,20 @@ export class Storage {

return signature;
}

private getError(testCaseId: string): CompoundError | undefined {
const testErrors = this.testCaseStartedErrors[testCaseId];

if (!testErrors) {
return undefined;
}

const error = new CompoundError();
testErrors.forEach((message) => {
error.addMessage(message);
error.addStacktrace(message);
});

return error;
}
}
Loading