@supatest/cypress-reporter 0.0.1 → 0.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
@@ -1,44 +1,180 @@
1
+ # @supatest/cypress-reporter
1
2
 
2
- ## Development
3
+ Supatest reporter for Cypress - stream test results to the Supatest dashboard in real-time.
3
4
 
4
- ### Running Tests
5
+ ## Installation
5
6
 
6
- **Integration Tests:**
7
7
  ```bash
8
- pnpm test:integration # Build reporter and run full E2E test suite
8
+ npm install @supatest/cypress-reporter --save-dev
9
+ # or
10
+ yarn add @supatest/cypress-reporter --dev
11
+ # or
12
+ pnpm add @supatest/cypress-reporter --save-dev
9
13
  ```
10
14
 
11
- This will:
12
- 1. Build the reporter package (`pnpm build`)
13
- 2. Run the Cypress test suite in `reporter-test-suites/cypress-saucedemo/`
14
- 3. Verify data flows to your local API (requires API running on `http://localhost:9090`)
15
+ ## Requirements
15
16
 
16
- **Quick Development Loop:**
17
- ```bash
18
- # Terminal 1: Start local API
19
- cd api && pnpm dev
17
+ - Node.js >= 18.0.0
18
+ - Cypress >= 12.0.0
19
+
20
+ ## Usage
21
+
22
+ Add the reporter plugin to your `cypress.config.ts` (or `cypress.config.js`):
23
+
24
+ ```typescript
25
+ // cypress.config.ts
26
+ import { defineConfig } from 'cypress';
27
+ import supatestPlugin from '@supatest/cypress-reporter';
20
28
 
21
- # Terminal 2: Build reporter, run integration tests
22
- cd cypress-reporter
23
- pnpm test:integration
29
+ export default defineConfig({
30
+ e2e: {
31
+ setupNodeEvents(on, config) {
32
+ supatestPlugin(on, config, {
33
+ projectId: process.env.SUPATEST_PROJECT_ID,
34
+ apiKey: process.env.SUPATEST_API_KEY,
35
+ });
36
+ return config;
37
+ },
38
+ },
39
+ });
24
40
  ```
25
41
 
26
- ### Test Suite Configuration
42
+ ### JavaScript
27
43
 
28
- The integration test suite uses `.env` configuration:
44
+ ```javascript
45
+ // cypress.config.js
46
+ const { defineConfig } = require('cypress');
47
+ const supatestPlugin = require('@supatest/cypress-reporter').default;
29
48
 
30
- ```bash
31
- # reporter-test-suites/cypress-saucedemo/.env
32
- SUPATEST_API_URL=http://localhost:9090
33
- SUPATEST_API_KEY=sk_test_...
34
- SUPATEST_PROJECT_ID=proj_local_swaglabs
35
- SUPATEST_DRY_RUN=false
49
+ module.exports = defineConfig({
50
+ e2e: {
51
+ setupNodeEvents(on, config) {
52
+ supatestPlugin(on, config, {
53
+ projectId: process.env.SUPATEST_PROJECT_ID,
54
+ apiKey: process.env.SUPATEST_API_KEY,
55
+ });
56
+ return config;
57
+ },
58
+ },
59
+ });
60
+ ```
61
+
62
+ ## Configuration Options
63
+
64
+ | Option | Type | Default | Description |
65
+ |--------|------|---------|-------------|
66
+ | `projectId` | `string` | - | **Required.** Your Supatest project ID. Can also be set via `SUPATEST_PROJECT_ID` env var. |
67
+ | `apiKey` | `string` | - | **Required.** Your Supatest API key. Can also be set via `SUPATEST_API_KEY` env var. |
68
+ | `apiUrl` | `string` | `https://code-api.supatest.ai` | API endpoint URL. |
69
+ | `uploadAssets` | `boolean` | `true` | Whether to upload screenshots and videos. |
70
+ | `maxConcurrentUploads` | `number` | `5` | Maximum concurrent attachment uploads. |
71
+ | `retryAttempts` | `number` | `3` | Number of retry attempts for failed API calls. |
72
+ | `timeoutMs` | `number` | `30000` | Timeout for API calls in milliseconds. |
73
+ | `dryRun` | `boolean` | `false` | Log payloads instead of sending to API. Useful for debugging. |
74
+
75
+ ## Environment Variables
76
+
77
+ | Variable | Description |
78
+ |----------|-------------|
79
+ | `SUPATEST_PROJECT_ID` | Your Supatest project ID |
80
+ | `SUPATEST_API_KEY` | Your Supatest API key |
81
+ | `SUPATEST_API_URL` | Custom API endpoint (optional) |
82
+ | `SUPATEST_DRY_RUN` | Set to `true` to enable dry-run mode |
83
+
84
+ ## Stable Test IDs
85
+
86
+ For consistent test tracking across runs, you can assign stable IDs to tests using the `@id:` tag:
87
+
88
+ ```javascript
89
+ describe('Login', () => {
90
+ it('@id:TC-001 should login with valid credentials', () => {
91
+ // Test implementation
92
+ });
93
+
94
+ it('@id:TC-002 should show error for invalid password', () => {
95
+ // Test implementation
96
+ });
97
+ });
36
98
  ```
37
99
 
38
- ### Verifying Integration Tests
100
+ If no explicit ID is provided, the reporter generates a stable hash based on the spec file path and test title hierarchy.
101
+
102
+ ## Test Tagging
103
+
104
+ Add tags to your test titles for better organization and filtering in the dashboard:
105
+
106
+ ```javascript
107
+ describe('Authentication Tests', () => {
108
+ it('@auth @smoke @priority:high Valid user can login', () => {
109
+ // ...
110
+ });
111
+
112
+ it('@auth @owner:team-auth @test_type:regression Locked user cannot login', () => {
113
+ // ...
114
+ });
115
+ });
116
+ ```
117
+
118
+ ### Supported Tags
119
+
120
+ | Tag Format | Example | Description |
121
+ |------------|---------|-------------|
122
+ | `@tagname` | `@smoke`, `@auth` | Simple tags for categorization |
123
+ | `@owner:name` | `@owner:team-auth` | Assign test ownership |
124
+ | `@priority:level` | `@priority:critical` | Priority: `critical`, `high`, `medium`, `low` |
125
+ | `@feature:name` | `@feature:login` | Feature grouping |
126
+ | `@test_type:type` | `@test_type:regression` | Test type: `smoke`, `e2e`, `regression`, `integration`, `unit` |
127
+ | `@slow` | `@slow` | Mark test as expected to be slow |
128
+ | `@flaky` | `@flaky` | Mark test as known flaky |
129
+
130
+ ## CI/CD Integration
131
+
132
+ The reporter automatically detects and captures CI/CD context from:
133
+
134
+ - GitHub Actions
135
+ - GitLab CI
136
+ - Jenkins
137
+ - CircleCI
138
+ - Travis CI
139
+ - Buildkite
140
+ - Azure Pipelines
141
+
142
+ Git information (branch, commit, author) is automatically extracted from both CI environment variables and local git repository.
143
+
144
+ ## Features
145
+
146
+ - Real-time test result streaming
147
+ - Screenshot and video uploads
148
+ - Retry tracking and flaky test detection
149
+ - Git and CI/CD metadata collection
150
+ - Browser information capture
151
+ - Non-blocking uploads (won't slow down your tests)
152
+ - Graceful error handling
153
+
154
+ ## Example
155
+
156
+ ```typescript
157
+ // cypress.config.ts
158
+ import { defineConfig } from 'cypress';
159
+ import supatestPlugin from '@supatest/cypress-reporter';
160
+
161
+ export default defineConfig({
162
+ e2e: {
163
+ baseUrl: 'https://example.com',
164
+ video: true,
165
+ screenshotOnRunFailure: true,
166
+ setupNodeEvents(on, config) {
167
+ supatestPlugin(on, config, {
168
+ projectId: 'proj_abc123',
169
+ apiKey: 'sk_test_xyz789',
170
+ uploadAssets: true,
171
+ });
172
+ return config;
173
+ },
174
+ },
175
+ });
176
+ ```
39
177
 
40
- After running `pnpm test:integration`, you should see:
41
- - `[supatest] Run <run-id> started (X spec files)`
42
- - `[supatest] Run <run-id> completed`
178
+ ## License
43
179
 
44
- Check your local API dashboard at `http://localhost:3000` to see the test results.
180
+ ISC
package/dist/index.d.cts CHANGED
@@ -1,5 +1,46 @@
1
- import { BaseReporterOptions } from '@supatest/reporter-core';
2
- export { ErrorCategory, ErrorCollector, ErrorSummary } from '@supatest/reporter-core';
1
+ type ErrorCategory = "RUN_CREATE" | "TEST_SUBMISSION" | "ATTACHMENT_SIGN" | "ATTACHMENT_UPLOAD" | "FILE_READ" | "RUN_COMPLETE";
2
+ type ReporterError = {
3
+ category: ErrorCategory;
4
+ message: string;
5
+ testId?: string;
6
+ testTitle?: string;
7
+ attachmentName?: string;
8
+ filePath?: string;
9
+ timestamp: string;
10
+ originalError?: string;
11
+ };
12
+ type ErrorSummary = {
13
+ totalErrors: number;
14
+ byCategory: Record<ErrorCategory, number>;
15
+ errors: ReporterError[];
16
+ };
17
+ type BaseReporterOptions = {
18
+ projectId: string;
19
+ apiKey: string;
20
+ apiUrl?: string;
21
+ uploadAssets?: boolean;
22
+ maxConcurrentUploads?: number;
23
+ retryAttempts?: number;
24
+ timeoutMs?: number;
25
+ dryRun?: boolean;
26
+ };
27
+
28
+ declare class ErrorCollector {
29
+ private errors;
30
+ recordError(category: ErrorCategory, message: string, context?: {
31
+ testId?: string;
32
+ testTitle?: string;
33
+ attachmentName?: string;
34
+ filePath?: string;
35
+ error?: unknown;
36
+ }): void;
37
+ getSummary(): ErrorSummary;
38
+ hasErrors(): boolean;
39
+ formatSummary(): string;
40
+ private getCategoryIcon;
41
+ private getCategoryLabel;
42
+ private formatError;
43
+ }
3
44
 
4
45
  type ReporterOptions = BaseReporterOptions;
5
46
 
@@ -106,4 +147,4 @@ type CypressPluginEvents = {
106
147
  type CypressPluginConfigOptions = Record<string, unknown>;
107
148
  declare function supatestPlugin(on: CypressPluginEvents, config: CypressPluginConfigOptions, options?: SupatestCypressOptions): void;
108
149
 
109
- export { type ReporterOptions, type SupatestCypressOptions, supatestPlugin as default };
150
+ export { type ErrorCategory, ErrorCollector, type ErrorSummary, type ReporterOptions, type SupatestCypressOptions, supatestPlugin as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,46 @@
1
- import { BaseReporterOptions } from '@supatest/reporter-core';
2
- export { ErrorCategory, ErrorCollector, ErrorSummary } from '@supatest/reporter-core';
1
+ type ErrorCategory = "RUN_CREATE" | "TEST_SUBMISSION" | "ATTACHMENT_SIGN" | "ATTACHMENT_UPLOAD" | "FILE_READ" | "RUN_COMPLETE";
2
+ type ReporterError = {
3
+ category: ErrorCategory;
4
+ message: string;
5
+ testId?: string;
6
+ testTitle?: string;
7
+ attachmentName?: string;
8
+ filePath?: string;
9
+ timestamp: string;
10
+ originalError?: string;
11
+ };
12
+ type ErrorSummary = {
13
+ totalErrors: number;
14
+ byCategory: Record<ErrorCategory, number>;
15
+ errors: ReporterError[];
16
+ };
17
+ type BaseReporterOptions = {
18
+ projectId: string;
19
+ apiKey: string;
20
+ apiUrl?: string;
21
+ uploadAssets?: boolean;
22
+ maxConcurrentUploads?: number;
23
+ retryAttempts?: number;
24
+ timeoutMs?: number;
25
+ dryRun?: boolean;
26
+ };
27
+
28
+ declare class ErrorCollector {
29
+ private errors;
30
+ recordError(category: ErrorCategory, message: string, context?: {
31
+ testId?: string;
32
+ testTitle?: string;
33
+ attachmentName?: string;
34
+ filePath?: string;
35
+ error?: unknown;
36
+ }): void;
37
+ getSummary(): ErrorSummary;
38
+ hasErrors(): boolean;
39
+ formatSummary(): string;
40
+ private getCategoryIcon;
41
+ private getCategoryLabel;
42
+ private formatError;
43
+ }
3
44
 
4
45
  type ReporterOptions = BaseReporterOptions;
5
46
 
@@ -106,4 +147,4 @@ type CypressPluginEvents = {
106
147
  type CypressPluginConfigOptions = Record<string, unknown>;
107
148
  declare function supatestPlugin(on: CypressPluginEvents, config: CypressPluginConfigOptions, options?: SupatestCypressOptions): void;
108
149
 
109
- export { type ReporterOptions, type SupatestCypressOptions, supatestPlugin as default };
150
+ export { type ErrorCategory, ErrorCollector, type ErrorSummary, type ReporterOptions, type SupatestCypressOptions, supatestPlugin as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supatest/cypress-reporter",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Supatest Cypress reporter - stream test results to Supatest dashboard",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,8 @@
28
28
  "@types/node": "^20.12.12",
29
29
  "cypress": "^13.0.0",
30
30
  "tsup": "^8.5.1",
31
- "typescript": "^5.4.5"
31
+ "typescript": "^5.4.5",
32
+ "@supatest/reporter-core": "0.0.1"
32
33
  },
33
34
  "engines": {
34
35
  "node": ">=18.0.0"