vitest-qase-reporter 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ Testing frameworks that use Vitest as a test runner can also be used with Vitest
11
11
  To install the latest version, run:
12
12
 
13
13
  ```shell
14
- npm install --save-dev qase-vitest
14
+ npm install vitest-qase-reporter
15
15
  ```
16
16
 
17
17
  # Contents
@@ -23,6 +23,7 @@ npm install --save-dev qase-vitest
23
23
  - [Metadata](#metadata)
24
24
  - [Advanced Usage with Annotations](#advanced-usage-with-annotations)
25
25
  - [Configuration](#configuration)
26
+ - [Documentation](#documentation)
26
27
  - [Requirements](#requirements)
27
28
 
28
29
  ## Getting started
@@ -94,22 +95,22 @@ existing test cases from TMS before the executing tests. For example:
94
95
 
95
96
  ```typescript
96
97
  import { describe, it, test, expect } from 'vitest';
97
- import { qase, withQase } from 'vitest-qase-reporter/vitest';
98
+ import { addQaseId, withQase } from 'vitest-qase-reporter/vitest';
98
99
 
99
100
  describe('My First Test', () => {
100
- test(qase([1, 2], 'Several ids'), () => {
101
+ test(addQaseId('Several ids', [1, 2]), () => {
101
102
  expect(true).toBe(true);
102
103
  });
103
104
 
104
- test(qase(3, 'Correct test'), () => {
105
+ test(addQaseId('Correct test', [3]), () => {
105
106
  expect(true).toBe(true);
106
107
  });
107
108
 
108
- test.skip(qase('4', 'Skipped test'), () => {
109
+ test.skip(addQaseId('Skipped test', [4]), () => {
109
110
  expect(true).toBe(true);
110
111
  });
111
112
 
112
- test(qase(['5', '6'], 'Failed test'), () => {
113
+ test(addQaseId('Failed test', ['5', '6']), () => {
113
114
  expect(true).toBe(false);
114
115
  });
115
116
  });
@@ -119,10 +120,10 @@ describe('My First Test', () => {
119
120
 
120
121
  ```typescript
121
122
  import { describe, it, expect } from 'vitest';
122
- import { qase, withQase } from 'vitest-qase-reporter/vitest';
123
+ import { addQaseId, withQase } from 'vitest-qase-reporter/vitest';
123
124
 
124
125
  describe('Qase Annotations Example', () => {
125
- it(qase(20, 'Basic test with qase ID'), () => {
126
+ it(addQaseId(20, 'Basic test with qase ID'), () => {
126
127
  expect(1 + 1).toBe(2);
127
128
  });
128
129
 
package/changelog.md CHANGED
@@ -1,3 +1,15 @@
1
+ # qase-vitest@1.0.3
2
+
3
+ ## What's new
4
+
5
+ - Added support for expected results and data for steps.
6
+
7
+ # qase-vitest@1.0.2
8
+
9
+ ## What's new
10
+
11
+ - Fixed an issue with attachments.
12
+
1
13
  # qase-vitest@1.0.1
2
14
 
3
15
  ## What's new
package/dist/index.d.ts CHANGED
@@ -35,5 +35,6 @@ export declare class VitestQaseReporter implements Reporter {
35
35
  onTestSuiteReady?(testSuite: TestSuite): void;
36
36
  onTestSuiteResult?(): void;
37
37
  private extractSuiteFromTestCase;
38
+ private extractAndCleanStep;
38
39
  }
39
40
  export default VitestQaseReporter;
package/dist/index.js CHANGED
@@ -126,10 +126,11 @@ class VitestQaseReporter {
126
126
  testResult.steps = metadata.steps.map(step => {
127
127
  const stepObj = new qase_javascript_commons_1.TestStepType();
128
128
  stepObj.id = Math.random().toString(36).substr(2, 9);
129
+ const stepData = this.extractAndCleanStep(step.name);
129
130
  stepObj.data = {
130
- action: step.name,
131
- expected_result: null,
132
- data: null
131
+ action: stepData.cleanedString,
132
+ expected_result: stepData.expectedResult,
133
+ data: stepData.data
133
134
  };
134
135
  stepObj.execution.status = step.status === 'failed' ? qase_javascript_commons_1.StepStatusEnum.failed : qase_javascript_commons_1.StepStatusEnum.passed;
135
136
  return stepObj;
@@ -242,14 +243,20 @@ class VitestQaseReporter {
242
243
  }
243
244
  case 'step-end': {
244
245
  if (metadata.currentStep) {
245
- metadata.steps.push({ name: metadata.currentStep, status: 'end' });
246
+ metadata.steps.push({
247
+ name: metadata.currentStep,
248
+ status: 'end'
249
+ });
246
250
  delete metadata.currentStep;
247
251
  }
248
252
  break;
249
253
  }
250
254
  case 'step-failed': {
251
255
  if (metadata.currentStep) {
252
- metadata.steps.push({ name: metadata.currentStep, status: 'failed' });
256
+ metadata.steps.push({
257
+ name: metadata.currentStep,
258
+ status: 'failed'
259
+ });
253
260
  delete metadata.currentStep;
254
261
  }
255
262
  break;
@@ -295,6 +302,26 @@ class VitestQaseReporter {
295
302
  // The test will be assigned to the default suite
296
303
  return undefined;
297
304
  }
305
+ extractAndCleanStep(input) {
306
+ let expectedResult = null;
307
+ let data = null;
308
+ let cleanedString = input;
309
+ const hasExpectedResult = input.includes('QaseExpRes:');
310
+ const hasData = input.includes('QaseData:');
311
+ if (hasExpectedResult || hasData) {
312
+ const regex = /QaseExpRes:\s*:?\s*(.*?)\s*(?=QaseData:|$)QaseData:\s*:?\s*(.*)?/;
313
+ const match = input.match(regex);
314
+ if (match) {
315
+ expectedResult = match[1]?.trim() ?? null;
316
+ data = match[2]?.trim() ?? null;
317
+ cleanedString = input
318
+ .replace(/QaseExpRes:\s*:?\s*.*?(?=QaseData:|$)/, '')
319
+ .replace(/QaseData:\s*:?\s*.*/, '')
320
+ .trim();
321
+ }
322
+ }
323
+ return { expectedResult, data, cleanedString };
324
+ }
298
325
  }
299
326
  exports.VitestQaseReporter = VitestQaseReporter;
300
327
  exports.default = VitestQaseReporter;
package/dist/vitest.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface QaseWrapper {
9
9
  fields(values: Record<string, string>): Promise<void>;
10
10
  parameters(values: Record<string, string>): Promise<void>;
11
11
  groupParameters(values: Record<string, string>): Promise<void>;
12
- step(name: string, body: StepFunction): Promise<void>;
12
+ step(name: string, body: StepFunction, expectedResult?: string, data?: string): Promise<void>;
13
13
  attach(attach: {
14
14
  name?: string;
15
15
  type?: string;
package/dist/vitest.js CHANGED
@@ -97,6 +97,8 @@ const createQaseWrapper = (annotate) => {
97
97
  * Add a step to the test case
98
98
  * @param name
99
99
  * @param body
100
+ * @param expectedResult
101
+ * @param data
100
102
  * @example
101
103
  * test('test', withQase(async ({ qase }) => {
102
104
  * await qase.step("Step", () => {
@@ -104,20 +106,30 @@ const createQaseWrapper = (annotate) => {
104
106
  * });
105
107
  * expect(true).toBe(true);
106
108
  * }));
109
+ * @example
110
+ * test('test', withQase(async ({ qase }) => {
111
+ * await qase.step("Step", () => {
112
+ * expect(true).toBe(true);
113
+ * }, "Expected result", "Input data");
114
+ * expect(true).toBe(true);
115
+ * }));
107
116
  */
108
- async step(name, body) {
109
- await annotate(`Qase Step Start: ${name}`, { type: 'qase-step-start', body: name });
117
+ async step(name, body, expectedResult, data) {
118
+ const stepName = expectedResult || data
119
+ ? `${name} QaseExpRes:${expectedResult ? `: ${expectedResult}` : ''} QaseData:${data ? `: ${data}` : ''}`
120
+ : name;
121
+ await annotate(`Qase Step Start: ${stepName}`, { type: 'qase-step-start', body: stepName });
110
122
  try {
111
- const runningStep = new qase_javascript_commons_1.QaseStep(name);
123
+ const runningStep = new qase_javascript_commons_1.QaseStep(stepName);
112
124
  await runningStep.run(body, async (step) => {
113
125
  const stepName = 'action' in step.data ? step.data.action : step.data.name;
114
126
  await annotate(`Qase Step: ${stepName}`, { type: 'qase-step', body: stepName });
115
127
  });
116
- await annotate(`Qase Step End: ${name}`, { type: 'qase-step-end', body: name });
128
+ await annotate(`Qase Step End: ${stepName}`, { type: 'qase-step-end', body: stepName });
117
129
  }
118
130
  catch (error) {
119
131
  const errorMessage = error instanceof Error ? error.message : String(error);
120
- await annotate(`Qase Step Failed: ${name} - ${errorMessage}`, { type: 'qase-step-failed', body: `${name} - ${errorMessage}` });
132
+ await annotate(`Qase Step Failed: ${stepName} - ${errorMessage}`, { type: 'qase-step-failed', body: `${stepName} - ${errorMessage}` });
121
133
  throw error;
122
134
  }
123
135
  },
package/docs/usage.md CHANGED
@@ -66,6 +66,8 @@ The reporter uses the title from the `qase.step` function as the step title. By
66
66
 
67
67
  Additionally, these steps get their own result in the Qase Test run, offering a well-organized summary of the test flow. This helps quickly identify the cause of any failures.
68
68
 
69
+ You can also provide an expected result and input data for each step, which will be displayed in Qase.
70
+
69
71
  ```typescript
70
72
  it('A Test case with steps, updated from code', withQase(async ({ qase }) => {
71
73
  await qase.step('Initialize the environment', async () => {
@@ -80,6 +82,20 @@ it('A Test case with steps, updated from code', withQase(async ({ qase }) => {
80
82
  });
81
83
  }));
82
84
  ```
85
+
86
+ #### Steps with Expected Result and Data
87
+
88
+ ```typescript
89
+ it('A Test case with steps including expected results and data', withQase(async ({ qase }) => {
90
+ await qase.step('Click button', async () => {
91
+ // Click action
92
+ }, 'Button should be clicked', 'Button data');
93
+
94
+ await qase.step('Fill form', async () => {
95
+ // Form filling action
96
+ }, 'Form should be filled', 'Form input data');
97
+ }));
98
+ ```
83
99
  <br>
84
100
 
85
101
  ### Fields
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-qase-reporter",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Qase TMS Vitest Reporter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -40,18 +40,18 @@
40
40
  "author": "Qase Team <support@qase.io>",
41
41
  "license": "Apache-2.0",
42
42
  "dependencies": {
43
- "qase-javascript-commons": "~2.4.2"
43
+ "qase-javascript-commons": "~2.4.13"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "vitest": ">=3.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@jest/globals": "^29.5.0",
50
- "@types/jest": "^29.5.2",
51
- "@types/node": "^20.0.0",
52
- "ajv": "^8.12.0",
53
- "jest": "^29.5.0",
54
- "ts-jest": "^29.1.0",
55
- "typescript": "^5.0.0"
49
+ "@jest/globals": "^29.7.0",
50
+ "@types/jest": "^29.5.14",
51
+ "@types/node": "^20.19.25",
52
+ "ajv": "^8.17.1",
53
+ "jest": "^29.7.0",
54
+ "ts-jest": "^29.4.5",
55
+ "typescript": "^5.9.3"
56
56
  }
57
57
  }
@@ -3,7 +3,8 @@
3
3
 
4
4
  "compilerOptions": {
5
5
  "noEmit": false,
6
- "skipLibCheck": true
6
+ "skipLibCheck": true,
7
+ "types": []
7
8
  },
8
9
 
9
10
  "include": ["./src/**/*.ts"]