@alternative-path/testlens-playwright-reporter 0.4.0 → 0.4.2

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.
Files changed (4) hide show
  1. package/index.d.ts +2 -2
  2. package/index.js +13 -12
  3. package/index.ts +15 -12
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -159,8 +159,8 @@ export declare class TestLensReporter implements Reporter {
159
159
  private axiosInstance;
160
160
  /**
161
161
  * Get bundled CA certificates for TestLens
162
- * Uses custom CA bundle packaged with the reporter
163
- * This ensures SSL works out-of-the-box without relying on system certificates
162
+ * Combines custom CA bundle with Node.js root certificates
163
+ * This ensures SSL works with both testlens.qa-path.com and other HTTPS endpoints
164
164
  */
165
165
  private static getBundledCaCertificates;
166
166
  /**
package/index.js CHANGED
@@ -23,12 +23,13 @@ async function getMime() {
23
23
  class TestLensReporter {
24
24
  /**
25
25
  * Get bundled CA certificates for TestLens
26
- * Uses custom CA bundle packaged with the reporter
27
- * This ensures SSL works out-of-the-box without relying on system certificates
26
+ * Combines custom CA bundle with Node.js root certificates
27
+ * This ensures SSL works with both testlens.qa-path.com and other HTTPS endpoints
28
28
  */
29
29
  static getBundledCaCertificates() {
30
+ const allCerts = [];
31
+ // First, add our bundled TestLens CA certificate chain
30
32
  try {
31
- // Load the bundled CA certificate file for testlens.qa-path.com
32
33
  const certPath = path.join(__dirname, 'testlens-ca-bundle.pem');
33
34
  if (fs.existsSync(certPath)) {
34
35
  const certData = fs.readFileSync(certPath, 'utf8');
@@ -36,26 +37,26 @@ class TestLensReporter {
36
37
  const certs = certData.match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g);
37
38
  if (certs && certs.length > 0) {
38
39
  const buffers = certs.map(cert => Buffer.from(cert, 'utf8'));
40
+ allCerts.push(...buffers);
39
41
  if (process.env.DEBUG) {
40
- console.log(`✓ Using bundled TestLens CA certificates (${buffers.length} certificate(s))`);
42
+ console.log(`✓ Loaded bundled TestLens CA certificates (${buffers.length} certificate(s))`);
41
43
  }
42
- return buffers;
43
44
  }
44
45
  }
45
46
  }
46
47
  catch (error) {
47
48
  if (process.env.DEBUG) {
48
- console.log('⚠️ Bundled CA certificate not available, will use fallback');
49
+ console.log('⚠️ Bundled CA certificate not available');
49
50
  }
50
51
  }
51
- // Fallback to Node.js built-in root certificates
52
+ // Then, add Node.js built-in root certificates for general SSL support
52
53
  try {
53
54
  if (tls.rootCertificates && Array.isArray(tls.rootCertificates) && tls.rootCertificates.length > 0) {
54
55
  const rootCerts = tls.rootCertificates.map(cert => Buffer.from(cert, 'utf8'));
56
+ allCerts.push(...rootCerts);
55
57
  if (process.env.DEBUG) {
56
- console.log(`✓ Using Node.js built-in root certificates (${rootCerts.length} certificates)`);
58
+ console.log(`✓ Added Node.js built-in root certificates (${rootCerts.length} certificates)`);
57
59
  }
58
- return rootCerts;
59
60
  }
60
61
  }
61
62
  catch (error) {
@@ -63,7 +64,7 @@ class TestLensReporter {
63
64
  console.log('⚠️ Node.js built-in root certificates not available');
64
65
  }
65
66
  }
66
- return undefined;
67
+ return allCerts.length > 0 ? allCerts : undefined;
67
68
  }
68
69
  /**
69
70
  * Automatically detect and load system CA certificates
@@ -1210,8 +1211,8 @@ class TestLensReporter {
1210
1211
  maxContentLength: Infinity,
1211
1212
  maxBodyLength: Infinity,
1212
1213
  timeout: Math.max(600000, Math.ceil(fileSize / (1024 * 1024)) * 10000), // 10s per MB, min 10 minutes - increased for large trace files
1213
- // Don't use custom HTTPS agent for S3 uploads
1214
- httpsAgent: undefined
1214
+ // Use the same HTTPS agent with CA certificates for S3 uploads
1215
+ httpsAgent: this.axiosInstance.defaults.httpsAgent
1215
1216
  });
1216
1217
  if (uploadResponse.status !== 200) {
1217
1218
  throw new Error(`S3 upload failed with status ${uploadResponse.status}`);
package/index.ts CHANGED
@@ -186,12 +186,14 @@ export class TestLensReporter implements Reporter {
186
186
 
187
187
  /**
188
188
  * Get bundled CA certificates for TestLens
189
- * Uses custom CA bundle packaged with the reporter
190
- * This ensures SSL works out-of-the-box without relying on system certificates
189
+ * Combines custom CA bundle with Node.js root certificates
190
+ * This ensures SSL works with both testlens.qa-path.com and other HTTPS endpoints
191
191
  */
192
192
  private static getBundledCaCertificates(): Buffer[] | undefined {
193
+ const allCerts: Buffer[] = [];
194
+
195
+ // First, add our bundled TestLens CA certificate chain
193
196
  try {
194
- // Load the bundled CA certificate file for testlens.qa-path.com
195
197
  const certPath = path.join(__dirname, 'testlens-ca-bundle.pem');
196
198
  if (fs.existsSync(certPath)) {
197
199
  const certData = fs.readFileSync(certPath, 'utf8');
@@ -199,33 +201,34 @@ export class TestLensReporter implements Reporter {
199
201
  const certs = certData.match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g);
200
202
  if (certs && certs.length > 0) {
201
203
  const buffers = certs.map(cert => Buffer.from(cert, 'utf8'));
204
+ allCerts.push(...buffers);
202
205
  if (process.env.DEBUG) {
203
- console.log(`✓ Using bundled TestLens CA certificates (${buffers.length} certificate(s))`);
206
+ console.log(`✓ Loaded bundled TestLens CA certificates (${buffers.length} certificate(s))`);
204
207
  }
205
- return buffers;
206
208
  }
207
209
  }
208
210
  } catch (error) {
209
211
  if (process.env.DEBUG) {
210
- console.log('⚠️ Bundled CA certificate not available, will use fallback');
212
+ console.log('⚠️ Bundled CA certificate not available');
211
213
  }
212
214
  }
213
215
 
214
- // Fallback to Node.js built-in root certificates
216
+ // Then, add Node.js built-in root certificates for general SSL support
215
217
  try {
216
218
  if (tls.rootCertificates && Array.isArray(tls.rootCertificates) && tls.rootCertificates.length > 0) {
217
219
  const rootCerts = tls.rootCertificates.map(cert => Buffer.from(cert, 'utf8'));
220
+ allCerts.push(...rootCerts);
218
221
  if (process.env.DEBUG) {
219
- console.log(`✓ Using Node.js built-in root certificates (${rootCerts.length} certificates)`);
222
+ console.log(`✓ Added Node.js built-in root certificates (${rootCerts.length} certificates)`);
220
223
  }
221
- return rootCerts;
222
224
  }
223
225
  } catch (error) {
224
226
  if (process.env.DEBUG) {
225
227
  console.log('⚠️ Node.js built-in root certificates not available');
226
228
  }
227
229
  }
228
- return undefined;
230
+
231
+ return allCerts.length > 0 ? allCerts : undefined;
229
232
  }
230
233
 
231
234
  /**
@@ -1501,8 +1504,8 @@ export class TestLensReporter implements Reporter {
1501
1504
  maxContentLength: Infinity,
1502
1505
  maxBodyLength: Infinity,
1503
1506
  timeout: Math.max(600000, Math.ceil(fileSize / (1024 * 1024)) * 10000), // 10s per MB, min 10 minutes - increased for large trace files
1504
- // Don't use custom HTTPS agent for S3 uploads
1505
- httpsAgent: undefined
1507
+ // Use the same HTTPS agent with CA certificates for S3 uploads
1508
+ httpsAgent: (this.axiosInstance.defaults as any).httpsAgent
1506
1509
  });
1507
1510
 
1508
1511
  if (uploadResponse.status !== 200) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alternative-path/testlens-playwright-reporter",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Universal Playwright reporter for TestLens - works with both TypeScript and JavaScript projects",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",