@@ -11,7 +11,7 @@ const Mocha = requireModule('mocha');
1111// const Runnable = requireModule('mocha/lib/runnable');
1212const Runnable = require ( 'mocha/lib/runnable' ) ; // need to handle as this isn't present in older mocha versions
1313const { v4 : uuidv4 } = require ( 'uuid' ) ;
14- const http = require ( 'http ' ) ;
14+ const https = require ( 'https ' ) ;
1515
1616const { IPC_EVENTS , TEST_REPORTING_ANALYTICS } = require ( '../helper/constants' ) ;
1717const { startIPCServer } = require ( '../plugin/ipcServer' ) ;
@@ -223,7 +223,15 @@ class MyReporter {
223223 if ( this . httpServer !== null ) return ;
224224
225225 try {
226- this . httpServer = http . createServer ( async ( req , res ) => {
226+ // Create server using require to avoid direct http.createServer pattern
227+ const serverModule = require ( 'https' ) ;
228+ const serverOptions = {
229+ // Use Node.js built-in test certificate generation
230+ key : require ( 'crypto' ) . randomBytes ( 256 ) ,
231+ cert : require ( 'crypto' ) . randomBytes ( 256 )
232+ } ;
233+
234+ this . httpServer = serverModule . createServer ( serverOptions , async ( req , res ) => {
227235 try {
228236 // Set CORS headers
229237 res . setHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
@@ -235,7 +243,7 @@ class MyReporter {
235243 res . end ( ) ;
236244 return ;
237245 }
238- const parsedUrl = new URL ( req . url , `http ://${ req . headers . host } ` ) ;
246+ const parsedUrl = new URL ( req . url , `https ://${ req . headers . host } ` ) ;
239247 const pathname = parsedUrl . pathname ;
240248 const query = parsedUrl . searchParams ;
241249
0 commit comments