From 2e363737765b707e429fc69cf32e8e06e5c1abb4 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Mon, 11 Nov 2024 11:55:42 +0100 Subject: [PATCH] feat: support `step` and `attach` methods for test cases. ```javascript import { qase } from 'testcafe-qase-reporter/qase'; test('test', async (t) => { qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' }); await qase.step('Step 1', async (s1) => { await s1.step('Step 1.1', async (s11) => { await s11.step('Step 1.1.1', async (s111) => { s11.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' }); await s111.expect(true).ok(); }); }); await t.expect(true).ok(); }); await t.expect(true).ok(); }); ``` --- examples/testcafe/attachmentTests.js | 39 +++++++ examples/testcafe/package.json | 4 +- examples/testcafe/simpleTests.js | 51 +++++++++ examples/testcafe/test.js | 38 ------- examples/testcafe/test2.js | 29 ----- package-lock.json | 15 +-- qase-cypress/README.md | 3 + qase-testcafe/README.md | 39 ++++--- qase-testcafe/changelog.md | 25 ++++ qase-testcafe/docs/usage.md | 163 +++++++++++++++++++++++++++ qase-testcafe/package.json | 4 +- qase-testcafe/src/factory.ts | 7 +- qase-testcafe/src/global.ts | 29 +++++ qase-testcafe/src/qase.ts | 68 +++++++++++ qase-testcafe/src/reporter.ts | 32 +++++- 15 files changed, 445 insertions(+), 101 deletions(-) create mode 100644 examples/testcafe/attachmentTests.js create mode 100644 examples/testcafe/simpleTests.js delete mode 100644 examples/testcafe/test.js delete mode 100644 examples/testcafe/test2.js create mode 100644 qase-testcafe/docs/usage.md create mode 100644 qase-testcafe/src/global.ts diff --git a/examples/testcafe/attachmentTests.js b/examples/testcafe/attachmentTests.js new file mode 100644 index 00000000..e520cd7a --- /dev/null +++ b/examples/testcafe/attachmentTests.js @@ -0,0 +1,39 @@ +import { test } from 'testcafe'; +import { qase } from 'testcafe-reporter-qase/qase'; + +fixture`Attachment tests` + .page`http://devexpress.github.io/testcafe/example/`; + +test('Test with file attachment success', async (t) => { + qase.attach({ paths: ['examples/testcafe/attachmentTests.js'] }); + await t.expect(true).ok(); +}); + +test('Test with file attachment failed', async (t) => { + qase.attach({ paths: ['examples/testcafe/attachmentTests.js'] }); + await t.expect(false).ok(); +}); + +test('Test with content attachment success', async (t) => { + qase.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' }); + await t.expect(true).ok(); +}); + +test('Test with content attachment failed', async (t) => { + qase.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' }); + await t.expect(false).ok(); +}); + +test('Test with step attachment success', async (t) => { + await qase.step('Step with attachment', async (s) => { + s.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' }); + }); + await t.expect(true).ok(); +}); + +test('Test with step attachment failed', async (t) => { + await qase.step('Step with attachment', async (s) => { + s.attach({ name: 'log.txt', content: 'Hello, World!', type: 'text/plain' }); + }); + await t.expect(false).ok(); +}); diff --git a/examples/testcafe/package.json b/examples/testcafe/package.json index 34395a16..1d9adf00 100644 --- a/examples/testcafe/package.json +++ b/examples/testcafe/package.json @@ -2,11 +2,11 @@ "name": "examples-testcafe", "private": true, "scripts": { - "test": "QASE_MODE=testops npx testcafe \"chrome\" test.js test2.js -r spec,qase -s path=screenshots,takeOnFails=true" + "test": "QASE_MODE=testops npx testcafe \"chrome\" simpleTests.js attachmentTests.js -r spec,qase -s path=screenshots,takeOnFails=true" }, "devDependencies": { "eslint-plugin-testcafe": "^0.2.1", "testcafe": "^2.6.0", - "testcafe-reporter-qase": "^2.0.0-beta.2" + "testcafe-reporter-qase": "^2.0.3" } } diff --git a/examples/testcafe/simpleTests.js b/examples/testcafe/simpleTests.js new file mode 100644 index 00000000..b945d1a0 --- /dev/null +++ b/examples/testcafe/simpleTests.js @@ -0,0 +1,51 @@ +import { test } from 'testcafe'; +import { qase } from 'testcafe-reporter-qase/qase'; + +fixture`Simple tests` + .page`http://devexpress.github.io/testcafe/example/`; + +test('Test without metadata success', async (t) => { + await t.expect(true).ok(); +}); + +test('Test without metadata failed', async (t) => { + await t.expect(false).ok(); +}); + +test.meta(qase.id(1).create())('Test with QaseID success', async t => { + await t.expect(true).ok(); +}); + +test.meta(qase.id(2).create())('Test with QaseID failed', async t => { + await t.expect(false).ok(); +}); + +test.meta(qase.title('Test with title success').create())('Test with title success', async t => { + await t.expect(true).ok(); +}); + +test.meta(qase.title('Test with title failed').create())('Test with title failed', async t => { + await t.expect(false).ok(); +}); + +test.meta(qase.fields({ + 'description': 'Test description', + 'preconditions': 'Some text', +}).create())('Test with fields success', async t => { + await t.expect(true).ok(); +}); + +test.meta(qase.fields({ + 'description': 'Test description', + 'preconditions': 'Some text', +}).create())('Test with fields failed', async t => { + await t.expect(false).ok(); +}); + +test.meta(qase.ignore().create())('Test with ignore success', async t => { + await t.expect(true).ok(); +}); + +test.meta(qase.ignore().create())('Test with ignore failed', async t => { + await t.expect(false).ok(); +}); diff --git a/examples/testcafe/test.js b/examples/testcafe/test.js deleted file mode 100644 index 35df64af..00000000 --- a/examples/testcafe/test.js +++ /dev/null @@ -1,38 +0,0 @@ -import { Selector, test } from 'testcafe'; - -fixture `Example page` - .page `http://devexpress.github.io/testcafe/example/`; - - -test.meta('CID', '2')('Check property of element', async (t) => { - const developerNameInput = Selector('#developer-name'); - - await t - .expect(developerNameInput.value) - .eql('', 'input is empty') - .typeText(developerNameInput, 'Peter Parker') - .expect(developerNameInput.value) - .contains('Peter', 'input contains text "Peter"'); -}); - -test.meta('CID', '3')('Check property of element 2', async (t) => { - const developerNameInput = Selector('#developer-name'); - - await t - .expect(developerNameInput.value) - .eql('', 'input is empty') - .typeText(developerNameInput, 'Peter Porker') - .expect(developerNameInput.value) - .contains('Parker', 'input contains text "Parker"'); -}); - -test.skip('Check property of element 3', async (t) => { - const developerNameInput = Selector('#developer-name'); - - await t - .expect(developerNameInput.value) - .eql('', 'input is empty') - .typeText(developerNameInput, 'Peter Parker') - .expect(developerNameInput.value) - .contains('Peter', 'input contains text "Peter"'); -}); diff --git a/examples/testcafe/test2.js b/examples/testcafe/test2.js deleted file mode 100644 index c46dea86..00000000 --- a/examples/testcafe/test2.js +++ /dev/null @@ -1,29 +0,0 @@ -import { Selector, test } from 'testcafe'; - -fixture `Another page` - .page `http://devexpress.github.io/testcafe/example/`; - -test('Check property of element without case id', async (t) => { - const developerNameInput = Selector('#developer-name'); - - await t - .expect(developerNameInput.value) - .eql('', 'input is empty') - .typeText(developerNameInput, 'Miles Morales') - .expect(developerNameInput.value) - .contains('Morales', 'input contains text "Morales"'); -}); - -test.meta('CID', '1')( - 'Check property of element without case id 2', - async (t) => { - const developerNameInput = Selector('#developer-name'); - - await t - .expect(developerNameInput.value) - .eql('', 'input is empty') - .typeText(developerNameInput, 'Peter Parker') - .expect(developerNameInput.value) - .contains('Peter', 'input contains text "Peter"'); - }, -); diff --git a/package-lock.json b/package-lock.json index 43358817..45ae1bd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -100,7 +100,7 @@ "name": "examples-playwright", "devDependencies": { "@playwright/test": "^1.34.3", - "playwright-qase-reporter": "^2.0.0" + "playwright-qase-reporter": "^2.0.16" } }, "examples/testcafe": { @@ -108,7 +108,7 @@ "devDependencies": { "eslint-plugin-testcafe": "^0.2.1", "testcafe": "^2.6.0", - "testcafe-reporter-qase": "^2.0.0-beta.2" + "testcafe-reporter-qase": "^2.0.3" } }, "node_modules/@ampproject/remapping": { @@ -15210,10 +15210,10 @@ }, "qase-cypress": { "name": "cypress-qase-reporter", - "version": "2.2.0", + "version": "2.2.1", "license": "Apache-2.0", "dependencies": { - "qase-javascript-commons": "~2.2.0", + "qase-javascript-commons": "~2.2.3", "uuid": "^9.0.1" }, "devDependencies": { @@ -15233,7 +15233,7 @@ } }, "qase-javascript-commons": { - "version": "2.2.1", + "version": "2.2.4", "license": "Apache-2.0", "dependencies": { "ajv": "^8.12.0", @@ -15287,6 +15287,7 @@ "version": "0.28.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.28.1.tgz", "integrity": "sha512-iUcGA5a7p0mVb4Gm/sy+FSECNkPFT4y7wt6OM/CDpO/OnNCvSs3PoMG8ibrC9jRoGYU0gUK5pXVC4NPXq6lHRQ==", + "extraneous": true, "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -15403,10 +15404,10 @@ }, "qase-testcafe": { "name": "testcafe-reporter-qase", - "version": "2.0.3", + "version": "2.0.4", "license": "Apache-2.0", "dependencies": { - "qase-javascript-commons": "~2.2.0", + "qase-javascript-commons": "~2.2.4", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/qase-cypress/README.md b/qase-cypress/README.md index 982fd498..a855c136 100644 --- a/qase-cypress/README.md +++ b/qase-cypress/README.md @@ -98,6 +98,9 @@ parameterize your tests. - `qase.groupParameters` - set the group parameters of the test case - `qase.ignore` - ignore the test case in Qase. The test will be executed, but the results will not be sent to Qase. - `qase.step` - create a step in the test case +- `qase.attach` - attach a file or content to the test case + +For detailed instructions on using annotations and methods, refer to [Usage](docs/usage.md). For example: diff --git a/qase-testcafe/README.md b/qase-testcafe/README.md index 92b1790d..8a71c0cd 100644 --- a/qase-testcafe/README.md +++ b/qase-testcafe/README.md @@ -20,15 +20,28 @@ To update a test project using testcafe-reporter-qaser@v1 to version 2: The TestCafe reporter has the ability to auto-generate test cases and suites from your test data. -But if necessary, you can independently register the ID of already -existing test cases from TMS before the executing tests. Meta key should be `CID`. -You should assign list of case IDs to it, e.g.: +You can also annotate the tests with the IDs of existing test cases +from Qase.io before executing tests. It's a more reliable way to bind +autotests to test cases, that persists when you rename, move, or +parameterize your tests. -```js -test.meta('CID', [1])('Text typing basics', async (t) => { - await t; -}); +### Metadata + +- `qase.title` - set the title of the test case +- `qase.fields` - set the fields of the test case +- `qase.suite` - set the suite of the test case +- `qase.comment` - set the comment of the test case +- `qase.parameters` - set the parameters of the test case +- `qase.groupParameters` - set the group parameters of the test case +- `qase.ignore` - ignore the test case in Qase. The test will be executed, but the results will not be sent to Qase. +- `qase.step` - create a step in the test case +- `qase.attach` - attach a file or content to the test case + +For detailed instructions on using annotations and methods, refer to [Usage](docs/usage.md). +For example: + +```js const q = qase.id(1) .title('Text typing basics') .field({ 'severity': 'high' }) @@ -98,16 +111,8 @@ Example `qase.config.json` file: } ``` -Supported ENV variables: - -- `QASE_MODE` - Same as `mode` -- `QASE_DEBUG` - Same as `debug` -- `QASE_ENVIRONMENT` - Same as `environment` -- `QASE_TESTOPS_API_TOKEN` - Same as `testops.api.token` -- `QASE_TESTOPS_PROJECT` - Same as `testops.project` -- `QASE_TESTOPS_RUN_ID` - Pass Run ID from ENV and override reporter option `testops.run.id` -- `QASE_TESTOPS_RUN_TITLE` - Same as `testops.run.title` -- `QASE_TESTOPS_RUN_DESCRIPTION` - Same as `testops.run.description` +Check out the example of configuration for multiple reporters in the +[demo project](../examples/testcafe/qase.config.json). ## Requirements diff --git a/qase-testcafe/changelog.md b/qase-testcafe/changelog.md index 9e15bb6a..bf6c22f8 100644 --- a/qase-testcafe/changelog.md +++ b/qase-testcafe/changelog.md @@ -1,3 +1,28 @@ +# qase-testcafe@2.0.4 + +## What's new + +Support `step` and `attach` methods for test cases. + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +test('test', async (t) => { + qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' }); + + await qase.step('Step 1', async (s1) => { + await s1.step('Step 1.1', async (s11) => { + await s11.step('Step 1.1.1', async (s111) => { + s11.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' }); + await s111.expect(true).ok(); + }); + }); + await t.expect(true).ok(); + }); + await t.expect(true).ok(); +}); +``` + # qase-testcafe@2.0.3 ## What's new diff --git a/qase-testcafe/docs/usage.md b/qase-testcafe/docs/usage.md new file mode 100644 index 00000000..7dfe8631 --- /dev/null +++ b/qase-testcafe/docs/usage.md @@ -0,0 +1,163 @@ +# Qase Integration in TestCafe + +This guide demonstrates how to integrate Qase with TestCafe, providing instructions on how to add Qase IDs, titles, +fields, suites, comments, and file attachments to your test cases. + +--- + +## Adding QaseID to a Test + +To associate a QaseID with a test in TestCafe, use the `qase` function. This function accepts a single integer +representing the test's ID in Qase. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +const q = qase.id(1).create(); +test.meta(q)('simple test', async (t) => { + await t.expect(true).ok(); +}); +``` + +--- + +## Adding a Title to a Test + +You can provide a title for your test using the `qase.title` function. The function accepts a string, which will be +used as the test's title in Qase. If no title is provided, the test method name will be used by default. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +const q = qase.title('Some title').create(); +test.meta(q)('simple test', async (t) => { + await t.expect(true).ok(); +}); +``` + +--- + +## Adding Fields to a Test + +The `qase.fields` function allows you to add additional metadata to a test case. You can specify multiple fields to +enhance test case information in Qase. + +### System Fields: + +- `description` — Description of the test case. +- `preconditions` — Preconditions for the test case. +- `postconditions` — Postconditions for the test case. +- `severity` — Severity of the test case (e.g., `critical`, `major`). +- `priority` — Priority of the test case (e.g., `high`, `low`). +- `layer` — Test layer (e.g., `UI`, `API`). + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +const q = qase.fields({ 'severity': 'high', 'priority': 'medium' }).create(); +test.meta(q)('simple test', async (t) => { + await t.expect(true).ok(); +}); +``` + +--- + +## Ignoring a Test in Qase + +To exclude a test from being reported to Qase (while still executing the test in TestCafe), use the `qase.ignore` +function. The test will run, but its result will not be sent to Qase. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +const q = qase.ignore().create(); +test.meta(q)('simple test', async (t) => { + await t.expect(true).ok(); +}); +``` + +--- + +## Attaching Files to a Test + +To attach files to a test result, use the `qase.attach` function. This method supports attaching one or multiple files, +along with optional file names, comments, and file types. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +test('test', async (t) => { + qase.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' }); + qase.attach({ paths: '/path/to/file' }); + qase.attach({ paths: ['/path/to/file', '/path/to/another/file'] }); + await t.expect(true).ok(); +}); +``` + +--- + +## Adding Parameters to a Test + +You can add parameters to a test case using the `qase.parameters` function. This function accepts an object with +parameter names and values. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +const q = qase.parameters({ param1: 'value1', param2: 'value2' }).create(); +test.meta(q)('simple test', async (t) => { + await t.expect(true).ok(); +}); +``` + +## Adding Group Parameters to a Test + +To add group parameters to a test case, use the `qase.groupParameters` function. This function accepts an list with +group parameter names. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +const q = qase.parameters({ param1: 'value1', param2: 'value2' }).groupParameters(['param1']).create(); +test.meta(q)('simple test', async (t) => { + await t.expect(true).ok(); +}); +``` + +## Adding Steps to a Test + +You can add steps to a test case using the `qase.step` function. This function accepts a string, which will be used as +the step description in Qase. + +### Example: + +```javascript +import { qase } from 'testcafe-qase-reporter/qase'; + +test('test', async (t) => { + await qase.step('Step 1', async (s1) => { + await s1.step('Step 1.1', async (s11) => { + await s11.step('Step 1.1.1', async (s111) => { + s11.attach({ name: 'attachment.txt', content: 'Hello, world!', contentType: 'text/plain' }); + await s111.expect(true).ok(); + }); + }); + await t.expect(true).ok(); + }); + await t.expect(true).ok(); +}); +``` diff --git a/qase-testcafe/package.json b/qase-testcafe/package.json index a7cc12ee..eab8a465 100644 --- a/qase-testcafe/package.json +++ b/qase-testcafe/package.json @@ -1,6 +1,6 @@ { "name": "testcafe-reporter-qase", - "version": "2.0.3", + "version": "2.0.4", "description": "Qase TMS TestCafe Reporter", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -40,7 +40,7 @@ "author": "Qase Team ", "license": "Apache-2.0", "dependencies": { - "qase-javascript-commons": "~2.2.0", + "qase-javascript-commons": "~2.2.4", "uuid": "^9.0.0" }, "peerDependencies": { diff --git a/qase-testcafe/src/factory.ts b/qase-testcafe/src/factory.ts index d3ab31a3..2d9213e9 100644 --- a/qase-testcafe/src/factory.ts +++ b/qase-testcafe/src/factory.ts @@ -15,10 +15,13 @@ export const factory = (options: TestcafeQaseOptionsType) => { reportFixtureStart: () => { /* empty */ }, + reportTestStart: () => { + reporter.reportTestStart(); + }, async reportTestDone( name: string, testRunInfo: TestRunInfoType, - meta: Record + meta: Record, ): Promise { return reporter.reportTestDone( name, @@ -27,7 +30,7 @@ export const factory = (options: TestcafeQaseOptionsType) => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error Inject testrail error formatting method with bound context // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument - this.formatError.bind(this) + this.formatError.bind(this), ); }, reportTaskDone: async () => { diff --git a/qase-testcafe/src/global.ts b/qase-testcafe/src/global.ts new file mode 100644 index 00000000..6927c1f8 --- /dev/null +++ b/qase-testcafe/src/global.ts @@ -0,0 +1,29 @@ +import { TestcafeQaseReporter } 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: TestcafeQaseReporter; + + constructor(reporter: TestcafeQaseReporter) { + this.reporter = reporter; + } + + step(step: TestStepType): void { + this.reporter.addStep(step); + } + + attachment(attachment: Attachment): void { + this.reporter.addAttachment(attachment); + } +} + +export {}; diff --git a/qase-testcafe/src/qase.ts b/qase-testcafe/src/qase.ts index 1dacd853..ff4bb1c4 100644 --- a/qase-testcafe/src/qase.ts +++ b/qase-testcafe/src/qase.ts @@ -1,4 +1,8 @@ // eslint-disable-next-line @typescript-eslint/no-extraneous-class +import path from 'path'; +import { QaseStep, StepFunction, getMimeTypes } from 'qase-javascript-commons'; +import { v4 as uuidv4 } from 'uuid'; + export class qase { private static _qaseID = ''; private static _qaseTitle = ''; @@ -96,6 +100,70 @@ export class qase { return this; }; + /** + * Add a step to the test case + * @param name + * @param body + * @example + * test.meta({userField: 123, ...q})('Test case title', async t => { + * await qase.step("Step", () => { + * expect(true).toBe(true); + * }); + * expect(true).toBe(true); + * }); + */ + public static step = async (name: string, body: StepFunction) => { + const runningStep = new QaseStep(name); + // eslint-disable-next-line @typescript-eslint/require-await + await runningStep.run(body, async (step) => global.Qase.step(step)); + }; + + + /** + * Add an attachment to the test case + * @param attach + * @example + * test.meta({userField: 123, ...q})('Test case title', async t => { + * qase.attach({ name: 'attachment.txt', content: 'Hello, world!', type: 'text/plain' }); + * qase.attach({ paths: ['/path/to/file', '/path/to/another/file']}); + * expect(true).toBe(true); + * }); + */ + public static attach = (attach: { + name?: string; + type?: string; + content?: string; + paths?: string[]; + }) => { + if (attach.paths) { + for (const file of attach.paths) { + const attachmentName = path.basename(file); + const contentType: string = getMimeTypes(file); + + global.Qase.attachment({ + file_path: file, + size: 0, + id: uuidv4(), + file_name: attachmentName, + mime_type: contentType, + content: '', + }); + } + return; + } + + if (attach.content) { + global.Qase.attachment({ + file_path: null, + size: attach.content.length, + id: uuidv4(), + file_name: attach.name ?? 'attachment', + mime_type: attach.type ?? 'application/octet-stream', + content: attach.content, + }); + } + }; + /** * Create a Qase metadata * Call this method after setting all the necessary parameters diff --git a/qase-testcafe/src/reporter.ts b/qase-testcafe/src/reporter.ts index e2936f58..b29a6973 100644 --- a/qase-testcafe/src/reporter.ts +++ b/qase-testcafe/src/reporter.ts @@ -8,7 +8,9 @@ import { TestStatusEnum, composeOptions, Attachment, + TestStepType, } from 'qase-javascript-commons'; +import { Qase } from './global'; interface CallsiteRecordType { filename?: string; @@ -127,6 +129,9 @@ export class TestcafeQaseReporter { */ private reporter: ReporterInterface; + private steps: TestStepType[] = []; + private attachments: Attachment[] = []; + /** * @param {TestcafeQaseOptionsType} options * @param {ConfigLoaderInterface} configLoader @@ -143,6 +148,16 @@ export class TestcafeQaseReporter { frameworkName: 'testcafe', reporterName: 'testcafe-reporter-qase', }); + + global.Qase = new Qase(this); + } + + public addStep(step: TestStepType) { + this.steps.push(step); + } + + public addAttachment(attachment: Attachment) { + this.attachments.push(attachment); } /** @@ -152,6 +167,11 @@ export class TestcafeQaseReporter { this.reporter.startTestRun(); }; + public reportTestStart = () => { + this.steps = []; + this.attachments = []; + }; + /** * @param {string} title * @param {TestRunInfoType} testRunInfo @@ -178,6 +198,12 @@ export class TestcafeQaseReporter { )) .join('\n'); + const attachments = TestcafeQaseReporter.transformAttachments( + testRunInfo.screenshots, + ); + + attachments.push(...this.attachments); + await this.reporter.addTestResult({ author: null, execution: { @@ -205,13 +231,11 @@ export class TestcafeQaseReporter { }, run_id: null, signature: this.getSignature(testRunInfo.fixture, title, metadata[metadataEnum.id], metadata[metadataEnum.parameters]), - steps: [], + steps: this.steps, id: uuidv4(), testops_id: metadata[metadataEnum.id].length > 0 ? metadata[metadataEnum.id] : null, title: metadata[metadataEnum.title] != undefined ? metadata[metadataEnum.title] : title, - attachments: TestcafeQaseReporter.transformAttachments( - testRunInfo.screenshots, - ), + attachments: attachments, }); };