11import axios from 'axios' ;
2+ import https from 'https' ;
23import fs from 'fs' ;
34
45let harEntries = [ ] ;
@@ -16,7 +17,7 @@ function createHarEntry(t, request, response) {
1617 cookies : [ ] ,
1718 headers : Object . entries ( request . headers )
1819 . filter ( ( [ _ , value ] ) => value !== undefined && value !== null && value !== '' )
19- . map ( ( [ name , value ] ) => ( { name, value} ) ) ,
20+ . map ( ( [ name , value ] ) => ( { name, value } ) ) ,
2021 queryString : [ ] ,
2122 postData : request . data ? {
2223 mimeType : request . headers [ 'Content-Type' ] || 'application/json' ,
@@ -32,7 +33,7 @@ function createHarEntry(t, request, response) {
3233 cookies : [ ] ,
3334 headers : Object . entries ( response . headers )
3435 . filter ( ( [ _ , value ] ) => value !== undefined && value !== null && value !== '' )
35- . map ( ( [ name , value ] ) => ( { name, value} ) ) ,
36+ . map ( ( [ name , value ] ) => ( { name, value } ) ) ,
3637 content : {
3738 size : - 1 ,
3839 mimeType : response . headers [ 'content-type' ] || 'application/json' ,
@@ -52,7 +53,7 @@ function createHarEntry(t, request, response) {
5253}
5354
5455export function writeHarFile ( testName ) {
55-
56+
5657 const har = {
5758 log : {
5859 version : '1.2' ,
@@ -64,7 +65,7 @@ export function writeHarFile(testName) {
6465 entries : harEntries
6566 }
6667 } ;
67-
68+
6869 const harPath = testName ;
6970 fs . writeFileSync ( harPath , JSON . stringify ( har , null , 2 ) ) ;
7071 harEntries = [ ] ; // Clear entries after writing
@@ -90,7 +91,8 @@ export function getAxiosInstance(config, testContext = null) {
9091 validateStatus : function ( status ) {
9192 // Return true for any status code (don't throw errors)
9293 return true ;
93- }
94+ } ,
95+ ...( config . skipTlsVerification && { httpsAgent : new https . Agent ( { rejectUnauthorized : false } ) } )
9496 } ) ;
9597
9698 const t = testContext ;
@@ -103,8 +105,8 @@ export function getAxiosInstance(config, testContext = null) {
103105 // Add response interceptor to log the raw HTTP response
104106 instance . interceptors . response . use ( response => {
105107 const harEntry = createHarEntry ( t , response . config , response ) ;
106-
107- if ( process . env . HAR_VIA_DIAGNOSTIC ) {
108+
109+ if ( process . env . HAR_VIA_DIAGNOSTIC ) {
108110 t ?. diagnostic ( harEntry ) ;
109111 }
110112
@@ -114,8 +116,8 @@ export function getAxiosInstance(config, testContext = null) {
114116 } , error => {
115117 if ( error . response ) {
116118 const harEntry = createHarEntry ( error . response . config , error . response ) ;
117-
118- if ( process . env . HAR_VIA_DIAGNOSTIC ) {
119+
120+ if ( process . env . HAR_VIA_DIAGNOSTIC ) {
119121 t ?. diagnostic ( harEntry ) ;
120122 }
121123
@@ -126,7 +128,7 @@ export function getAxiosInstance(config, testContext = null) {
126128 return instance ;
127129}
128130
129- export function canonicalize ( resource , schema ) {
131+ export function canonicalize ( resource , schema ) {
130132 // Create a deep copy of the user object
131133 const canonicalizedResource = JSON . parse ( JSON . stringify ( resource ) ) ;
132134 const schemas = canonicalizedResource . schemas || [ ] ;
@@ -140,14 +142,14 @@ export function canonicalize(resource, schema){
140142 if ( ! canonicalizedResource [ coreSchema ] ) {
141143 canonicalizedResource [ coreSchema ] = { } ;
142144 }
143-
145+
144146 // Move attributes that are not schemas, meta, id, or extension schemas to the core schema
145147 Object . keys ( canonicalizedResource ) . forEach ( key => {
146148 // Skip schemas, meta, id, and extension schemas (which start with urn: but aren't the core schema)
147149 if ( key === 'schemas' || key === 'meta' || key === 'id' || key == 'externalId' || schemas . includes ( key ) ) {
148150 return ;
149151 }
150-
152+
151153 // Move the attribute to the core schema and delete from root
152154 canonicalizedResource [ coreSchema ] [ key ] = canonicalizedResource [ key ] ;
153155 delete canonicalizedResource [ key ] ;
0 commit comments