-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: added the ability to specify a test metadata in tests
- `qase.title` - set the test title - `qase.fields` - set the test fields - `qase.suite` - set the test suite - `qase.comment` - set the test comment - `qase.parameters` - set the test parameters - `qase.groupParameters` - set the test group parameters - `qase.ignore` - ignore the test in Qase - `qase.attach` - attach a file to the test - `qase.steps` - add the test steps ```ts const { qase } = require('jest-qase-reporter/jest'); test('test', () => { qase.title('Title'); qase.fields({ custom_field: 'value' }); qase.suite('Suite'); qase.comment('Comment'); qase.parameters({ param01: 'value' }); qase.groupParameters({ param02: 'value' }); qase.ignore(); qase.attach({ name: 'attachment.txt', content: 'Hello, world!', type: 'text/plain' }); qase.step('Step 1', () => { expect(true).toBe(true); }); expect(true).toBe(true); }); ```
- Loading branch information
Showing
8 changed files
with
615 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
# [email protected] | ||
|
||
## What's new | ||
|
||
Added the ability to specify a test metadata in tests: | ||
|
||
- `qase.title` - set the test title | ||
- `qase.fields` - set the test fields | ||
- `qase.suite` - set the test suite | ||
- `qase.comment` - set the test comment | ||
- `qase.parameters` - set the test parameters | ||
- `qase.groupParameters` - set the test group parameters | ||
- `qase.ignore` - ignore the test in Qase | ||
- `qase.attach` - attach a file to the test | ||
- `qase.steps` - add the test steps | ||
|
||
```ts | ||
const { qase } = require('jest-qase-reporter/jest'); | ||
|
||
test('test', () => { | ||
qase.title('Title'); | ||
qase.fields({ custom_field: 'value' }); | ||
qase.suite('Suite'); | ||
qase.comment('Comment'); | ||
qase.parameters({ param01: 'value' }); | ||
qase.groupParameters({ param02: 'value' }); | ||
qase.ignore(); | ||
qase.attach({ name: 'attachment.txt', content: 'Hello, world!', type: 'text/plain' }); | ||
|
||
qase.step('Step 1', () => { | ||
expect(true).toBe(true); | ||
}); | ||
|
||
expect(true).toBe(true); | ||
}); | ||
``` | ||
|
||
# [email protected] | ||
|
||
## What's new | ||
|
||
Fixed a bug when a test was marked as skipped. | ||
This reporter has uploaded this test as blocked. | ||
This reporter has uploaded this test as blocked. | ||
Right now the reporter will upload this test as skipped. | ||
|
||
# [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { JestQaseReporter } from './reporter'; | ||
import { Attachment, TestStepType } from 'qase-javascript-commons'; | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace NodeJS { | ||
interface Global { | ||
Qase: Qase; | ||
} | ||
} | ||
} | ||
|
||
export class Qase { | ||
private reporter: JestQaseReporter; | ||
|
||
constructor(reporter: JestQaseReporter) { | ||
this.reporter = reporter; | ||
} | ||
|
||
title(title: string): void { | ||
this.reporter.addTitle(title); | ||
} | ||
|
||
ignore(): void { | ||
this.reporter.addIgnore(); | ||
} | ||
|
||
comment(value: string): void { | ||
this.reporter.addComment(value); | ||
} | ||
|
||
suite(value: string): void { | ||
this.reporter.addSuite(value); | ||
} | ||
|
||
fields(values: Record<string, string>): void { | ||
const stringRecord: Record<string, string> = {}; | ||
for (const [key, value] of Object.entries(values)) { | ||
stringRecord[String(key)] = String(value); | ||
} | ||
this.reporter.addFields(stringRecord); | ||
} | ||
|
||
parameters(values: Record<string, string>): void { | ||
const stringRecord: Record<string, string> = {}; | ||
for (const [key, value] of Object.entries(values)) { | ||
stringRecord[String(key)] = String(value); | ||
} | ||
this.reporter.addParameters(stringRecord); | ||
} | ||
|
||
groupParams(values: Record<string, string>): void { | ||
const stringRecord: Record<string, string> = {}; | ||
for (const [key, value] of Object.entries(values)) { | ||
stringRecord[String(key)] = String(value); | ||
} | ||
this.reporter.addGroupParams(stringRecord); | ||
} | ||
|
||
step(step: TestStepType): void { | ||
this.reporter.addStep(step); | ||
} | ||
|
||
attachment(attachment: Attachment): void { | ||
this.reporter.addAttachment(attachment); | ||
} | ||
} | ||
|
||
export {}; |
Oops, something went wrong.