testlens-playwright-reporter 0.3.3 → 0.3.4

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/cross-env.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Cross-platform wrapper for cross-env
4
+ *
5
+ * This wrapper allows users to set environment variables in a cross-platform way
6
+ * without needing to install cross-env separately.
7
+ *
8
+ * Platform Support:
9
+ * - Windows (PowerShell, CMD)
10
+ * - macOS (bash, zsh, etc.)
11
+ * - Linux (bash, sh, etc.)
12
+ * - Any platform that runs Node.js
13
+ *
14
+ * Usage:
15
+ * npx testlens-cross-env VAR1=value1 VAR2=value2 command args...
16
+ *
17
+ * Example:
18
+ * npx testlens-cross-env testlensApiKey="abc123" playwright test
19
+ */
20
+
21
+ const crossEnv = require('cross-env');
22
+
23
+ // Pass all command-line arguments to cross-env
24
+ crossEnv(process.argv.slice(2));
package/index.d.ts CHANGED
@@ -1,120 +1,191 @@
1
- import { Reporter } from '@playwright/test/reporter';
2
-
3
- export interface TestLensReporterConfig {
4
- /** TestLens API endpoint URL */
5
- apiEndpoint?: string;
6
- /** API key for authentication - required, must be provided in config */
7
- apiKey: string;
8
- /** Enable real-time streaming of test events */
9
- enableRealTimeStream?: boolean;
10
- /** Enable Git information collection */
11
- enableGitInfo?: boolean;
12
- /** Enable artifact processing */
13
- enableArtifacts?: boolean;
14
- /** Enable video capture - defaults to true */
15
- enableVideo?: boolean;
16
- /** Enable screenshot capture - defaults to true */
17
- enableScreenshot?: boolean;
18
- /** Batch size for API requests */
19
- batchSize?: number;
20
- /** Flush interval in milliseconds */
21
- flushInterval?: number;
22
- /** Number of retry attempts for failed API calls */
23
- retryAttempts?: number;
24
- /** Request timeout in milliseconds */
25
- timeout?: number;
26
- /** SSL certificate validation - set to false to disable SSL verification */
27
- rejectUnauthorized?: boolean;
28
- /** Alternative SSL option - set to true to ignore SSL certificate errors */
29
- ignoreSslErrors?: boolean;
30
- }
31
-
32
- export interface TestLensReporterOptions {
33
- /** TestLens API endpoint URL */
34
- apiEndpoint?: string;
35
- /** API key for authentication - required, must be provided in config */
36
- apiKey: string;
37
- /** Enable real-time streaming of test events */
38
- enableRealTimeStream?: boolean;
39
- /** Enable Git information collection */
40
- enableGitInfo?: boolean;
41
- /** Enable artifact processing */
42
- enableArtifacts?: boolean;
43
- /** Enable video capture - defaults to true */
44
- enableVideo?: boolean;
45
- /** Enable screenshot capture - defaults to true */
46
- enableScreenshot?: boolean;
47
- /** Batch size for API requests */
48
- batchSize?: number;
49
- /** Flush interval in milliseconds */
50
- flushInterval?: number;
51
- /** Number of retry attempts for failed API calls */
52
- retryAttempts?: number;
53
- /** Request timeout in milliseconds */
54
- timeout?: number;
55
- /** SSL certificate validation - set to false to disable SSL verification */
56
- rejectUnauthorized?: boolean;
57
- /** Alternative SSL option - set to true to ignore SSL certificate errors */
58
- ignoreSslErrors?: boolean;
59
- }
60
-
61
- export interface GitInfo {
62
- branch: string;
63
- commit: string;
64
- shortCommit: string;
65
- author: string;
66
- message: string;
67
- timestamp: string;
68
- isDirty: boolean;
69
- remoteName: string;
70
- remoteUrl: string;
71
- }
72
-
73
- /** Rich error details from Playwright */
74
- export interface TestError {
75
- message: string;
76
- stack?: string;
77
- location?: {
78
- file: string;
79
- line: number;
80
- column: number;
81
- };
82
- snippet?: string;
83
- expected?: string;
84
- actual?: string;
85
- diff?: string;
86
- matcherName?: string;
87
- timeout?: number;
88
- }
89
-
90
- export interface TestData {
91
- id: string;
92
- name: string;
93
- status: string;
94
- originalStatus?: string;
95
- duration: number;
96
- startTime: string;
97
- endTime: string;
98
- errorMessages: string[];
99
- errors?: TestError[];
100
- retryAttempts: number;
101
- currentRetry: number;
102
- annotations: Array<{ type: string; description?: string }>;
103
- projectName: string;
104
- workerIndex?: number;
105
- parallelIndex?: number;
106
- location?: {
107
- file: string;
108
- line: number;
109
- column: number;
110
- };
111
- }
112
-
113
- export default class TestLensReporter implements Reporter {
114
- constructor(options: TestLensReporterOptions);
115
-
116
- onBegin?(config: import('@playwright/test/reporter').FullConfig, suite: import('@playwright/test/reporter').Suite): void;
117
- onTestBegin?(test: import('@playwright/test/reporter').TestCase, result: import('@playwright/test/reporter').TestResult): void;
118
- onTestEnd?(test: import('@playwright/test/reporter').TestCase, result: import('@playwright/test/reporter').TestResult): void;
119
- onEnd?(result: import('@playwright/test/reporter').FullResult): Promise<void>;
120
- }
1
+ import type { Reporter, TestCase, TestResult, FullConfig, Suite } from '@playwright/test/reporter';
2
+ export interface TestLensReporterConfig {
3
+ /** TestLens API endpoint URL */
4
+ apiEndpoint?: string;
5
+ /** API key for authentication - can be provided in config or via TESTLENS_API_KEY environment variable */
6
+ apiKey?: string;
7
+ /** Enable real-time streaming of test events */
8
+ enableRealTimeStream?: boolean;
9
+ /** Enable Git information collection */
10
+ enableGitInfo?: boolean;
11
+ /** Enable artifact processing */
12
+ enableArtifacts?: boolean;
13
+ /** Enable video capture - defaults to true */
14
+ enableVideo?: boolean;
15
+ /** Enable screenshot capture - defaults to true */
16
+ enableScreenshot?: boolean;
17
+ /** Batch size for API requests */
18
+ batchSize?: number;
19
+ /** Flush interval in milliseconds */
20
+ flushInterval?: number;
21
+ /** Number of retry attempts for failed API calls */
22
+ retryAttempts?: number;
23
+ /** Request timeout in milliseconds */
24
+ timeout?: number;
25
+ /** SSL certificate validation - set to false to disable SSL verification */
26
+ rejectUnauthorized?: boolean;
27
+ /** Alternative SSL option - set to true to ignore SSL certificate errors */
28
+ ignoreSslErrors?: boolean;
29
+ /** Custom metadata from CLI arguments (automatically parsed from --key=value arguments) */
30
+ customMetadata?: Record<string, string>;
31
+ }
32
+ export interface TestLensReporterOptions {
33
+ /** TestLens API endpoint URL */
34
+ apiEndpoint?: string;
35
+ /** API key for authentication - can be provided in config or via TESTLENS_API_KEY environment variable */
36
+ apiKey?: string;
37
+ /** Enable real-time streaming of test events */
38
+ enableRealTimeStream?: boolean;
39
+ /** Enable Git information collection */
40
+ enableGitInfo?: boolean;
41
+ /** Enable artifact processing */
42
+ enableArtifacts?: boolean;
43
+ /** Enable video capture - defaults to true */
44
+ enableVideo?: boolean;
45
+ /** Enable screenshot capture - defaults to true */
46
+ enableScreenshot?: boolean;
47
+ /** Batch size for API requests */
48
+ batchSize?: number;
49
+ /** Flush interval in milliseconds */
50
+ flushInterval?: number;
51
+ /** Number of retry attempts for failed API calls */
52
+ retryAttempts?: number;
53
+ /** Request timeout in milliseconds */
54
+ timeout?: number;
55
+ /** SSL certificate validation - set to false to disable SSL verification */
56
+ rejectUnauthorized?: boolean;
57
+ /** Alternative SSL option - set to true to ignore SSL certificate errors */
58
+ ignoreSslErrors?: boolean;
59
+ /** Custom metadata from CLI arguments (automatically parsed from --key=value arguments) */
60
+ customMetadata?: Record<string, string>;
61
+ }
62
+ export interface GitInfo {
63
+ branch: string;
64
+ commit: string;
65
+ shortCommit: string;
66
+ author: string;
67
+ message: string;
68
+ timestamp: string;
69
+ isDirty: boolean;
70
+ remoteName: string;
71
+ remoteUrl: string;
72
+ }
73
+ export interface CodeBlock {
74
+ type: 'test' | 'describe';
75
+ name: string;
76
+ content: string;
77
+ summary?: string;
78
+ describe?: string;
79
+ startLine?: number;
80
+ endLine?: number;
81
+ }
82
+ export interface RunMetadata {
83
+ id: string;
84
+ startTime: string;
85
+ endTime?: string;
86
+ duration?: number;
87
+ environment: string;
88
+ browser: string;
89
+ os: string;
90
+ playwrightVersion: string;
91
+ nodeVersion: string;
92
+ gitInfo?: GitInfo | null;
93
+ shardInfo?: {
94
+ current: number;
95
+ total: number;
96
+ };
97
+ totalTests?: number;
98
+ passedTests?: number;
99
+ failedTests?: number;
100
+ skippedTests?: number;
101
+ status?: string;
102
+ testlensBuildName?: string;
103
+ customMetadata?: Record<string, string>;
104
+ }
105
+ export interface TestError {
106
+ message: string;
107
+ stack?: string;
108
+ location?: {
109
+ file: string;
110
+ line: number;
111
+ column: number;
112
+ };
113
+ snippet?: string;
114
+ expected?: string;
115
+ actual?: string;
116
+ diff?: string;
117
+ matcherName?: string;
118
+ timeout?: number;
119
+ }
120
+ export interface TestData {
121
+ id: string;
122
+ name: string;
123
+ status: string;
124
+ originalStatus?: string;
125
+ duration: number;
126
+ startTime: string;
127
+ endTime: string;
128
+ errorMessages: string[];
129
+ errors?: TestError[];
130
+ retryAttempts: number;
131
+ currentRetry: number;
132
+ annotations: Array<{
133
+ type: string;
134
+ description?: string;
135
+ }>;
136
+ projectName: string;
137
+ workerIndex?: number;
138
+ parallelIndex?: number;
139
+ location?: {
140
+ file: string;
141
+ line: number;
142
+ column: number;
143
+ };
144
+ }
145
+ export interface SpecData {
146
+ filePath: string;
147
+ testSuiteName: string;
148
+ tags?: string[];
149
+ startTime: string;
150
+ endTime?: string;
151
+ status: string;
152
+ }
153
+ export declare class TestLensReporter implements Reporter {
154
+ private config;
155
+ private axiosInstance;
156
+ private runId;
157
+ private runMetadata;
158
+ private specMap;
159
+ private testMap;
160
+ private runCreationFailed;
161
+ /**
162
+ * Parse custom metadata from environment variables
163
+ * Checks for common metadata environment variables
164
+ */
165
+ private static parseCustomArgs;
166
+ constructor(options: TestLensReporterOptions);
167
+ private initializeRunMetadata;
168
+ private getPlaywrightVersion;
169
+ private normalizeTestStatus;
170
+ private normalizeRunStatus;
171
+ onBegin(config: FullConfig, suite: Suite): Promise<void>;
172
+ onTestBegin(test: TestCase, result: TestResult): Promise<void>;
173
+ onTestEnd(test: TestCase, result: TestResult): Promise<void>;
174
+ onEnd(result: {
175
+ status: string;
176
+ }): Promise<void>;
177
+ private sendToApi;
178
+ private processArtifacts;
179
+ private sendSpecCodeBlocks;
180
+ private extractTestBlocks;
181
+ private collectGitInfo;
182
+ private getArtifactType;
183
+ private extractTags;
184
+ private getTestId;
185
+ private uploadArtifactToS3;
186
+ private getContentType;
187
+ private generateS3Key;
188
+ private sanitizeForS3;
189
+ private getFileSize;
190
+ }
191
+ export default TestLensReporter;