File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -143,14 +143,14 @@ const leakCheckerAfterEach = async function () {
143143const TRACE_SOCKETS = process . env . TRACE_SOCKETS === 'true' ? true : false ;
144144const kSocketId = Symbol ( 'socketId' ) ;
145145const originalCreateConnection = net . createConnection ;
146- let socketCounter = 0n ;
147146
148- const socketLeakCheckBeforeAll = function socketLeakCheckBeforeAll ( ) {
147+ const socketLeakCheckBeforeEach = function socketLeakCheckBeforeAll ( ) {
148+ const description = this . currentTest . title ;
149+ let id = 0 ;
149150 // @ts -expect-error: Typescript says this is readonly, but it is not at runtime
150151 net . createConnection = options => {
151152 const socket = originalCreateConnection ( options ) ;
152- socket [ kSocketId ] = socketCounter . toString ( ) . padStart ( 5 , '0' ) ;
153- socketCounter ++ ;
153+ socket [ kSocketId ] = `"${ description } " (${ id ++ } )` ;
154154 return socket ;
155155 } ;
156156} ;
@@ -175,7 +175,6 @@ const socketLeakCheckAfterEach: Mocha.AsyncFunc = async function socketLeakCheck
175175 }
176176} ;
177177
178- const beforeAll = TRACE_SOCKETS ? [ socketLeakCheckBeforeAll ] : [ ] ;
179- const beforeEach = [ leakCheckerBeforeEach ] ;
178+ const beforeEach = [ leakCheckerBeforeEach , ...( TRACE_SOCKETS ? [ socketLeakCheckBeforeEach ] : [ ] ) ] ;
180179const afterEach = [ leakCheckerAfterEach , ...( TRACE_SOCKETS ? [ socketLeakCheckAfterEach ] : [ ] ) ] ;
181- export const mochaHooks = { beforeAll , beforeEach, afterEach } ;
180+ export const mochaHooks = { beforeEach, afterEach } ;
You can’t perform that action at this time.
0 commit comments