qagentic-reporter 0.1.0

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 ADDED
@@ -0,0 +1,261 @@
1
+ # QAagentic JavaScript/TypeScript SDK
2
+
3
+ <p align="center">
4
+ <strong>AI-Powered Test Intelligence for JavaScript/TypeScript</strong>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@qagentic/reporter">
9
+ <img src="https://img.shields.io/npm/v/@qagentic/reporter.svg" alt="npm version">
10
+ </a>
11
+ <a href="https://github.com/qagentic/qagentic-sdk/blob/main/LICENSE">
12
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
13
+ </a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ ## 🚀 Installation
19
+
20
+ ```bash
21
+ npm install @qagentic/reporter
22
+ # or
23
+ yarn add @qagentic/reporter
24
+ # or
25
+ pnpm add @qagentic/reporter
26
+ ```
27
+
28
+ ## ⚡ Quick Start
29
+
30
+ ### Cypress
31
+
32
+ ```javascript
33
+ // cypress.config.js
34
+ const { defineConfig } = require('cypress');
35
+ const { qagentic } = require('@qagentic/reporter/cypress');
36
+
37
+ module.exports = defineConfig({
38
+ e2e: {
39
+ setupNodeEvents(on, config) {
40
+ qagentic(on, config, {
41
+ projectName: 'my-project',
42
+ apiUrl: 'http://localhost:8080',
43
+ });
44
+ return config;
45
+ },
46
+ },
47
+ });
48
+ ```
49
+
50
+ ### Playwright
51
+
52
+ ```typescript
53
+ // playwright.config.ts
54
+ import { defineConfig } from '@playwright/test';
55
+ import { qagenticReporter } from '@qagentic/reporter/playwright';
56
+
57
+ export default defineConfig({
58
+ reporter: [
59
+ ['html'],
60
+ qagenticReporter({
61
+ projectName: 'my-project',
62
+ apiUrl: 'http://localhost:8080',
63
+ }),
64
+ ],
65
+ });
66
+ ```
67
+
68
+ ### Jest
69
+
70
+ ```javascript
71
+ // jest.config.js
72
+ module.exports = {
73
+ reporters: [
74
+ 'default',
75
+ ['@qagentic/reporter/jest', {
76
+ projectName: 'my-project',
77
+ apiUrl: 'http://localhost:8080',
78
+ }],
79
+ ],
80
+ };
81
+ ```
82
+
83
+ ## 📝 Usage Examples
84
+
85
+ ### Steps in Cypress
86
+
87
+ ```javascript
88
+ // cypress/e2e/login.cy.js
89
+ import { step, feature, story, severity } from '@qagentic/reporter/cypress';
90
+
91
+ describe('User Authentication', () => {
92
+ it('should login successfully', () => {
93
+ step('Navigate to login page', () => {
94
+ cy.visit('/login');
95
+ });
96
+
97
+ step('Enter credentials', () => {
98
+ cy.get('#email').type('user@example.com');
99
+ cy.get('#password').type('password123');
100
+ });
101
+
102
+ step('Submit and verify', () => {
103
+ cy.get('button[type="submit"]').click();
104
+ cy.url().should('include', '/dashboard');
105
+ });
106
+ });
107
+ });
108
+ ```
109
+
110
+ ### Steps in Playwright
111
+
112
+ ```typescript
113
+ // tests/login.spec.ts
114
+ import { test, expect } from '@playwright/test';
115
+ import { step } from '@qagentic/reporter/playwright';
116
+
117
+ test('should login successfully', async ({ page }) => {
118
+ await step('Navigate to login page', async () => {
119
+ await page.goto('/login');
120
+ });
121
+
122
+ await step('Enter credentials', async () => {
123
+ await page.fill('#email', 'user@example.com');
124
+ await page.fill('#password', 'password123');
125
+ });
126
+
127
+ await step('Submit and verify', async () => {
128
+ await page.click('button[type="submit"]');
129
+ await expect(page).toHaveURL(/dashboard/);
130
+ });
131
+ });
132
+ ```
133
+
134
+ ### Attachments
135
+
136
+ ```javascript
137
+ import { attach, attachScreenshot, attachJson } from '@qagentic/reporter';
138
+
139
+ // Attach screenshot
140
+ attachScreenshot('path/to/screenshot.png', 'Login Page');
141
+
142
+ // Attach JSON data
143
+ attachJson({ status: 'success', userId: 123 }, 'API Response');
144
+
145
+ // Attach text
146
+ attachText('Log output here...', 'Console Logs');
147
+ ```
148
+
149
+ ## ⚙️ Configuration
150
+
151
+ ### Environment Variables
152
+
153
+ ```bash
154
+ QAGENTIC_PROJECT_NAME=my-project
155
+ QAGENTIC_API_URL=http://localhost:8080
156
+ QAGENTIC_API_KEY=your-api-key
157
+ QAGENTIC_OUTPUT_DIR=./qagentic-results
158
+ QAGENTIC_AI_ANALYSIS=true
159
+ ```
160
+
161
+ ### Configuration File
162
+
163
+ ```yaml
164
+ # qagentic.yaml
165
+ project:
166
+ name: my-project
167
+ environment: staging
168
+
169
+ reporting:
170
+ api:
171
+ enabled: true
172
+ url: http://localhost:8080
173
+ key: ${QAGENTIC_API_KEY}
174
+ local:
175
+ enabled: true
176
+ output_dir: ./qagentic-results
177
+ formats:
178
+ - json
179
+ - html
180
+ - junit
181
+
182
+ features:
183
+ ai_analysis: true
184
+ screenshots: on_failure
185
+ ```
186
+
187
+ ## 🔌 CI/CD Integration
188
+
189
+ ### GitHub Actions
190
+
191
+ ```yaml
192
+ - name: Run Cypress Tests
193
+ run: npx cypress run
194
+ env:
195
+ QAGENTIC_API_URL: ${{ secrets.QAGENTIC_API_URL }}
196
+ QAGENTIC_API_KEY: ${{ secrets.QAGENTIC_API_KEY }}
197
+
198
+ - name: Upload Results
199
+ uses: actions/upload-artifact@v3
200
+ if: always()
201
+ with:
202
+ name: qagentic-results
203
+ path: qagentic-results/
204
+ ```
205
+
206
+ ### GitLab CI
207
+
208
+ ```yaml
209
+ test:
210
+ script:
211
+ - npx cypress run
212
+ artifacts:
213
+ when: always
214
+ paths:
215
+ - qagentic-results/
216
+ reports:
217
+ junit: qagentic-results/junit.xml
218
+ ```
219
+
220
+ ## 📊 Output Formats
221
+
222
+ - **JSON Report** - Machine-readable results
223
+ - **JUnit XML** - CI/CD compatible
224
+ - **HTML Report** - Interactive dashboard
225
+
226
+ ## 🧠 AI Features
227
+
228
+ When connected to QAagentic server:
229
+
230
+ - **Automatic Root Cause Analysis**
231
+ - **Failure Clustering**
232
+ - **Flaky Test Detection**
233
+ - **Smart Recommendations**
234
+
235
+ ## 📚 API Reference
236
+
237
+ ### Core Functions
238
+
239
+ | Function | Description |
240
+ |----------|-------------|
241
+ | `step(name, fn)` | Create a test step |
242
+ | `attach(data, name)` | Attach data to test |
243
+ | `attachScreenshot(path)` | Attach screenshot |
244
+ | `attachJson(data)` | Attach JSON data |
245
+
246
+ ### Decorators/Labels
247
+
248
+ | Function | Description |
249
+ |----------|-------------|
250
+ | `feature(name)` | Group by feature |
251
+ | `story(name)` | Group by user story |
252
+ | `severity(level)` | Set severity level |
253
+ | `tag(...tags)` | Add tags |
254
+
255
+ ## 🤝 Contributing
256
+
257
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.
258
+
259
+ ## 📄 License
260
+
261
+ MIT License - see [LICENSE](../../LICENSE) for details.
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Test severity levels - compatible with Allure.
3
+ */
4
+ declare enum Severity {
5
+ BLOCKER = "blocker",
6
+ CRITICAL = "critical",
7
+ NORMAL = "normal",
8
+ MINOR = "minor",
9
+ TRIVIAL = "trivial"
10
+ }
11
+
12
+ /**
13
+ * Test execution status.
14
+ */
15
+ declare enum Status {
16
+ PASSED = "passed",
17
+ FAILED = "failed",
18
+ BROKEN = "broken",
19
+ SKIPPED = "skipped",
20
+ PENDING = "pending",
21
+ RUNNING = "running",
22
+ UNKNOWN = "unknown"
23
+ }
24
+
25
+ /**
26
+ * Core type definitions for QAagentic SDK.
27
+ */
28
+
29
+ /**
30
+ * Test step result.
31
+ */
32
+ interface StepResult {
33
+ id: string;
34
+ name: string;
35
+ status: Status;
36
+ startTime?: Date;
37
+ endTime?: Date;
38
+ durationMs: number;
39
+ error?: string;
40
+ errorTrace?: string;
41
+ attachments: Attachment[];
42
+ children: StepResult[];
43
+ parameters: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Attachment data.
47
+ */
48
+ interface Attachment {
49
+ id: string;
50
+ name: string;
51
+ type: string;
52
+ extension?: string;
53
+ content: string;
54
+ size: number;
55
+ timestamp: string;
56
+ }
57
+ /**
58
+ * Test labels and metadata.
59
+ */
60
+ interface TestLabels {
61
+ feature?: string;
62
+ story?: string;
63
+ epic?: string;
64
+ severity?: Severity;
65
+ tags?: string[];
66
+ owner?: string;
67
+ layer?: string;
68
+ suite?: string;
69
+ subSuite?: string;
70
+ parentSuite?: string;
71
+ [key: string]: unknown;
72
+ }
73
+ /**
74
+ * Link to external resource.
75
+ */
76
+ interface TestLink {
77
+ url: string;
78
+ name: string;
79
+ type: 'link' | 'issue' | 'tms';
80
+ }
81
+ /**
82
+ * Complete test result.
83
+ */
84
+ interface TestResult {
85
+ id: string;
86
+ name: string;
87
+ fullName: string;
88
+ description?: string;
89
+ status: Status;
90
+ startTime?: Date;
91
+ endTime?: Date;
92
+ durationMs: number;
93
+ errorMessage?: string;
94
+ errorType?: string;
95
+ stackTrace?: string;
96
+ labels: TestLabels;
97
+ links: TestLink[];
98
+ parameters: Record<string, unknown>;
99
+ steps: StepResult[];
100
+ attachments: Attachment[];
101
+ filePath?: string;
102
+ lineNumber?: number;
103
+ retryCount: number;
104
+ isRetry: boolean;
105
+ isFlaky: boolean;
106
+ flakyReason?: string;
107
+ }
108
+ /**
109
+ * Test run result containing multiple tests.
110
+ */
111
+ interface TestRunResult {
112
+ id: string;
113
+ name: string;
114
+ projectName: string;
115
+ environment: string;
116
+ startTime?: Date;
117
+ endTime?: Date;
118
+ durationMs: number;
119
+ tests: TestResult[];
120
+ total: number;
121
+ passed: number;
122
+ failed: number;
123
+ broken: number;
124
+ skipped: number;
125
+ passRate: number;
126
+ labels: Record<string, unknown>;
127
+ parameters: Record<string, unknown>;
128
+ ciBuildId?: string;
129
+ ciBuildUrl?: string;
130
+ branch?: string;
131
+ commitHash?: string;
132
+ }
133
+
134
+ /**
135
+ * Step context manager for defining test steps.
136
+ */
137
+
138
+ /**
139
+ * Represents a test step with timing and status tracking.
140
+ */
141
+ declare class Step {
142
+ readonly id: string;
143
+ readonly name: string;
144
+ readonly description?: string;
145
+ status: Status;
146
+ startTime?: Date;
147
+ endTime?: Date;
148
+ durationMs: number;
149
+ error?: string;
150
+ errorTrace?: string;
151
+ attachments: Attachment[];
152
+ children: Step[];
153
+ parameters: Record<string, unknown>;
154
+ constructor(name: string, description?: string, parameters?: Record<string, unknown>);
155
+ /**
156
+ * Start the step.
157
+ */
158
+ start(): this;
159
+ /**
160
+ * End the step.
161
+ */
162
+ end(error?: Error): this;
163
+ /**
164
+ * Attach data to this step.
165
+ */
166
+ attach(data: string | Buffer, name: string, type?: string): this;
167
+ /**
168
+ * Attach a screenshot.
169
+ */
170
+ attachScreenshot(path: string, name?: string): this;
171
+ /**
172
+ * Attach JSON data.
173
+ */
174
+ attachJson(data: unknown, name?: string): this;
175
+ /**
176
+ * Set a step parameter.
177
+ */
178
+ setParameter(name: string, value: unknown): this;
179
+ /**
180
+ * Convert to result object.
181
+ */
182
+ toResult(): StepResult;
183
+ }
184
+ /**
185
+ * Execute a function within a step context.
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * step('Login to application', () => {
190
+ * // test code
191
+ * });
192
+ *
193
+ * await step('Async operation', async () => {
194
+ * await someAsyncOperation();
195
+ * });
196
+ * ```
197
+ */
198
+ declare function step<T>(name: string, fn: () => T): T;
199
+ declare function step<T>(name: string, description: string, fn: () => T): T;
200
+
201
+ /**
202
+ * Decorators for annotating tests with metadata.
203
+ * Compatible with Allure-style annotations.
204
+ */
205
+
206
+ /**
207
+ * Mark test with a feature label.
208
+ */
209
+ declare function feature(name: string): <T extends object>(target: T) => T;
210
+ /**
211
+ * Mark test with a user story label.
212
+ */
213
+ declare function story(name: string): <T extends object>(target: T) => T;
214
+ /**
215
+ * Mark test with an epic label.
216
+ */
217
+ declare function epic(name: string): <T extends object>(target: T) => T;
218
+ /**
219
+ * Mark test with a severity level.
220
+ */
221
+ declare function severity(level: Severity | string): <T extends object>(target: T) => T;
222
+ /**
223
+ * Add tags to a test.
224
+ */
225
+ declare function tag(...tags: string[]): <T extends object>(target: T) => T;
226
+ /**
227
+ * Add a custom label to a test.
228
+ */
229
+ declare function label(name: string, value: string): <T extends object>(target: T) => T;
230
+ /**
231
+ * Add a link to a test.
232
+ */
233
+ declare function link(url: string, name?: string, type?: string): <T extends object>(target: T) => T;
234
+ /**
235
+ * Link test to an issue tracker.
236
+ */
237
+ declare function issue(url: string, name?: string): <T extends object>(target: T) => T;
238
+ /**
239
+ * Link test to a test management system.
240
+ */
241
+ declare function testcase(url: string, name?: string): <T extends object>(target: T) => T;
242
+ /**
243
+ * Add a description to a test.
244
+ */
245
+ declare function description(text: string): <T extends object>(target: T) => T;
246
+ /**
247
+ * Set a custom title for the test.
248
+ */
249
+ declare function title(name: string): <T extends object>(target: T) => T;
250
+ /**
251
+ * Set the test owner.
252
+ */
253
+ declare function owner(name: string): <T extends object>(target: T) => T;
254
+ /**
255
+ * Set the test layer.
256
+ */
257
+ declare function layer(name: string): <T extends object>(target: T) => T;
258
+ /**
259
+ * Set the suite name.
260
+ */
261
+ declare function suite(name: string): <T extends object>(target: T) => T;
262
+ /**
263
+ * Set the sub-suite name.
264
+ */
265
+ declare function subSuite(name: string): <T extends object>(target: T) => T;
266
+ /**
267
+ * Set the parent suite name.
268
+ */
269
+ declare function parentSuite(name: string): <T extends object>(target: T) => T;
270
+
271
+ /**
272
+ * Attachment utilities for adding files, screenshots, and data to test reports.
273
+ */
274
+
275
+ /**
276
+ * Attach data to the current test or step.
277
+ */
278
+ declare function attach(data: string | Buffer, name: string, type?: string, extension?: string): string;
279
+ /**
280
+ * Attach a file to the current test.
281
+ */
282
+ declare function attachFile(filePath: string, name?: string): string;
283
+ /**
284
+ * Attach a screenshot to the current test.
285
+ */
286
+ declare function attachScreenshot(data: string | Buffer, name?: string): string;
287
+ /**
288
+ * Attach JSON data to the current test.
289
+ */
290
+ declare function attachJson(data: unknown, name?: string): string;
291
+ /**
292
+ * Attach plain text to the current test.
293
+ */
294
+ declare function attachText(text: string, name?: string): string;
295
+ /**
296
+ * Attach HTML content to the current test.
297
+ */
298
+ declare function attachHtml(html: string, name?: string): string;
299
+ /**
300
+ * Attach a video to the current test.
301
+ */
302
+ declare function attachVideo(filePath: string, name?: string): string;
303
+
304
+ export { attachVideo as A, type StepResult as B, Severity as S, type TestRunResult as T, type TestResult as a, Status as b, Step as c, story as d, epic as e, feature as f, severity as g, link as h, issue as i, testcase as j, description as k, label as l, title as m, layer as n, owner as o, suite as p, subSuite as q, parentSuite as r, step as s, tag as t, attach as u, attachFile as v, attachScreenshot as w, attachJson as x, attachText as y, attachHtml as z };