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 () {
143
143
const TRACE_SOCKETS = process . env . TRACE_SOCKETS === 'true' ? true : false ;
144
144
const kSocketId = Symbol ( 'socketId' ) ;
145
145
const originalCreateConnection = net . createConnection ;
146
- let socketCounter = 0n ;
147
146
148
- const socketLeakCheckBeforeAll = function socketLeakCheckBeforeAll ( ) {
147
+ const socketLeakCheckBeforeEach = function socketLeakCheckBeforeAll ( ) {
148
+ const description = this . currentTest . title ;
149
+ let id = 0 ;
149
150
// @ts -expect-error: Typescript says this is readonly, but it is not at runtime
150
151
net . createConnection = options => {
151
152
const socket = originalCreateConnection ( options ) ;
152
- socket [ kSocketId ] = socketCounter . toString ( ) . padStart ( 5 , '0' ) ;
153
- socketCounter ++ ;
153
+ socket [ kSocketId ] = `"${ description } " (${ id ++ } )` ;
154
154
return socket ;
155
155
} ;
156
156
} ;
@@ -175,7 +175,6 @@ const socketLeakCheckAfterEach: Mocha.AsyncFunc = async function socketLeakCheck
175
175
}
176
176
} ;
177
177
178
- const beforeAll = TRACE_SOCKETS ? [ socketLeakCheckBeforeAll ] : [ ] ;
179
- const beforeEach = [ leakCheckerBeforeEach ] ;
178
+ const beforeEach = [ leakCheckerBeforeEach , ...( TRACE_SOCKETS ? [ socketLeakCheckBeforeEach ] : [ ] ) ] ;
180
179
const 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