testlens-playwright-reporter 0.3.4 → 0.3.5
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/index.js +19 -6
- package/index.ts +20 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -41,8 +41,15 @@ class TestLensReporter {
|
|
|
41
41
|
for (const envVar of envVars) {
|
|
42
42
|
const value = process.env[envVar];
|
|
43
43
|
if (value) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// For testlensBuildTag, support comma-separated values
|
|
45
|
+
if (key === 'testlensBuildTag' && value.includes(',')) {
|
|
46
|
+
customArgs[key] = value.split(',').map(tag => tag.trim()).filter(tag => tag);
|
|
47
|
+
console.log(`✓ Found ${envVar}=${value} (mapped to '${key}' as array of ${customArgs[key].length} tags)`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
customArgs[key] = value;
|
|
51
|
+
console.log(`✓ Found ${envVar}=${value} (mapped to '${key}')`);
|
|
52
|
+
}
|
|
46
53
|
break; // Use first match
|
|
47
54
|
}
|
|
48
55
|
}
|
|
@@ -51,8 +58,10 @@ class TestLensReporter {
|
|
|
51
58
|
}
|
|
52
59
|
constructor(options) {
|
|
53
60
|
this.runCreationFailed = false; // Track if run creation failed due to limits
|
|
61
|
+
this.cliArgs = {}; // Store CLI args separately
|
|
54
62
|
// Parse custom CLI arguments
|
|
55
63
|
const customArgs = TestLensReporter.parseCustomArgs();
|
|
64
|
+
this.cliArgs = customArgs; // Store CLI args separately for later use
|
|
56
65
|
// Allow API key from environment variable if not provided in config
|
|
57
66
|
// Check multiple environment variable names in priority order (uppercase and lowercase)
|
|
58
67
|
const apiKey = options.apiKey
|
|
@@ -77,7 +86,7 @@ class TestLensReporter {
|
|
|
77
86
|
flushInterval: options.flushInterval || 5000,
|
|
78
87
|
retryAttempts: options.retryAttempts !== undefined ? options.retryAttempts : 0,
|
|
79
88
|
timeout: options.timeout || 60000,
|
|
80
|
-
customMetadata: { ...
|
|
89
|
+
customMetadata: { ...options.customMetadata, ...customArgs } // Config metadata first, then CLI args override
|
|
81
90
|
};
|
|
82
91
|
if (!this.config.apiKey) {
|
|
83
92
|
throw new Error('API_KEY is required for TestLensReporter. Pass it as apiKey option in your playwright config or set one of these environment variables: TESTLENS_API_KEY, TESTLENS_KEY, PLAYWRIGHT_API_KEY, PW_API_KEY, API_KEY, or APIKEY.');
|
|
@@ -893,9 +902,13 @@ class TestLensReporter {
|
|
|
893
902
|
if (tagMatches) {
|
|
894
903
|
tags.push(...tagMatches);
|
|
895
904
|
}
|
|
896
|
-
// Add testlensBuildTag
|
|
897
|
-
|
|
898
|
-
|
|
905
|
+
// Add testlensBuildTag: CLI args take precedence over config
|
|
906
|
+
const buildTagSource = this.cliArgs.testlensBuildTag || this.config.customMetadata?.testlensBuildTag;
|
|
907
|
+
if (buildTagSource) {
|
|
908
|
+
const buildTags = Array.isArray(buildTagSource)
|
|
909
|
+
? buildTagSource
|
|
910
|
+
: [buildTagSource];
|
|
911
|
+
buildTags.forEach(tag => tags.push(`@${tag}`));
|
|
899
912
|
}
|
|
900
913
|
// Remove duplicates and return
|
|
901
914
|
return [...new Set(tags)];
|
package/index.ts
CHANGED
|
@@ -183,13 +183,14 @@ export class TestLensReporter implements Reporter {
|
|
|
183
183
|
private specMap: Map<string, SpecData>;
|
|
184
184
|
private testMap: Map<string, TestData>;
|
|
185
185
|
private runCreationFailed: boolean = false; // Track if run creation failed due to limits
|
|
186
|
+
private cliArgs: Record<string, any> = {}; // Store CLI args separately
|
|
186
187
|
|
|
187
188
|
/**
|
|
188
189
|
* Parse custom metadata from environment variables
|
|
189
190
|
* Checks for common metadata environment variables
|
|
190
191
|
*/
|
|
191
|
-
private static parseCustomArgs(): Record<string,
|
|
192
|
-
const customArgs: Record<string,
|
|
192
|
+
private static parseCustomArgs(): Record<string, any> {
|
|
193
|
+
const customArgs: Record<string, any> = {};
|
|
193
194
|
|
|
194
195
|
// Common environment variable names for build metadata
|
|
195
196
|
const envVarMappings: Record<string, string[]> = {
|
|
@@ -207,8 +208,14 @@ export class TestLensReporter implements Reporter {
|
|
|
207
208
|
for (const envVar of envVars) {
|
|
208
209
|
const value = process.env[envVar];
|
|
209
210
|
if (value) {
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
// For testlensBuildTag, support comma-separated values
|
|
212
|
+
if (key === 'testlensBuildTag' && value.includes(',')) {
|
|
213
|
+
customArgs[key] = value.split(',').map(tag => tag.trim()).filter(tag => tag);
|
|
214
|
+
console.log(`✓ Found ${envVar}=${value} (mapped to '${key}' as array of ${customArgs[key].length} tags)`);
|
|
215
|
+
} else {
|
|
216
|
+
customArgs[key] = value;
|
|
217
|
+
console.log(`✓ Found ${envVar}=${value} (mapped to '${key}')`);
|
|
218
|
+
}
|
|
212
219
|
break; // Use first match
|
|
213
220
|
}
|
|
214
221
|
}
|
|
@@ -220,6 +227,7 @@ export class TestLensReporter implements Reporter {
|
|
|
220
227
|
constructor(options: TestLensReporterOptions) {
|
|
221
228
|
// Parse custom CLI arguments
|
|
222
229
|
const customArgs = TestLensReporter.parseCustomArgs();
|
|
230
|
+
this.cliArgs = customArgs; // Store CLI args separately for later use
|
|
223
231
|
|
|
224
232
|
// Allow API key from environment variable if not provided in config
|
|
225
233
|
// Check multiple environment variable names in priority order (uppercase and lowercase)
|
|
@@ -246,7 +254,7 @@ export class TestLensReporter implements Reporter {
|
|
|
246
254
|
flushInterval: options.flushInterval || 5000,
|
|
247
255
|
retryAttempts: options.retryAttempts !== undefined ? options.retryAttempts : 0,
|
|
248
256
|
timeout: options.timeout || 60000,
|
|
249
|
-
customMetadata: { ...
|
|
257
|
+
customMetadata: { ...options.customMetadata, ...customArgs } // Config metadata first, then CLI args override
|
|
250
258
|
} as Required<TestLensReporterConfig>;
|
|
251
259
|
|
|
252
260
|
if (!this.config.apiKey) {
|
|
@@ -1152,9 +1160,13 @@ export class TestLensReporter implements Reporter {
|
|
|
1152
1160
|
tags.push(...tagMatches);
|
|
1153
1161
|
}
|
|
1154
1162
|
|
|
1155
|
-
// Add testlensBuildTag
|
|
1156
|
-
|
|
1157
|
-
|
|
1163
|
+
// Add testlensBuildTag: CLI args take precedence over config
|
|
1164
|
+
const buildTagSource = this.cliArgs.testlensBuildTag || this.config.customMetadata?.testlensBuildTag;
|
|
1165
|
+
if (buildTagSource) {
|
|
1166
|
+
const buildTags = Array.isArray(buildTagSource)
|
|
1167
|
+
? buildTagSource
|
|
1168
|
+
: [buildTagSource];
|
|
1169
|
+
buildTags.forEach(tag => tags.push(`@${tag}`));
|
|
1158
1170
|
}
|
|
1159
1171
|
|
|
1160
1172
|
// Remove duplicates and return
|
package/package.json
CHANGED