diff --git a/packages/web3-core/test/unit/__snapshots__/web3_context.test.ts.snap b/packages/web3-core/test/unit/__snapshots__/web3_context.test.ts.snap index b9f0d4f0c95..b832a1f8200 100644 --- a/packages/web3-core/test/unit/__snapshots__/web3_context.test.ts.snap +++ b/packages/web3-core/test/unit/__snapshots__/web3_context.test.ts.snap @@ -40,7 +40,7 @@ exports[`Web3Context getContextObject should return correct context object 1`] = }, "registeredSubscriptions": {}, "requestManager": Web3RequestManager { - "_emitter": EventEmitter { + "_emitter": { "_events": { "BEFORE_PROVIDER_CHANGE": [Function], "PROVIDER_CHANGED": [Function], @@ -48,6 +48,7 @@ exports[`Web3Context getContextObject should return correct context object 1`] = "_eventsCount": 2, "_maxListeners": undefined, Symbol(kCapture): false, + Symbol(shapeMode): false, }, "_provider": HttpProvider { "clientUrl": "http://test/abc", @@ -59,7 +60,7 @@ exports[`Web3Context getContextObject should return correct context object 1`] = "_subscriptions": Map {}, "registeredSubscriptions": {}, "requestManager": Web3RequestManager { - "_emitter": EventEmitter { + "_emitter": { "_events": { "BEFORE_PROVIDER_CHANGE": [Function], "PROVIDER_CHANGED": [Function], @@ -67,6 +68,7 @@ exports[`Web3Context getContextObject should return correct context object 1`] = "_eventsCount": 2, "_maxListeners": undefined, Symbol(kCapture): false, + Symbol(shapeMode): false, }, "_provider": HttpProvider { "clientUrl": "http://test/abc", diff --git a/packages/web3-core/test/unit/web3_context.test.ts b/packages/web3-core/test/unit/web3_context.test.ts index 1bedd82ba5b..3c433f7259a 100644 --- a/packages/web3-core/test/unit/web3_context.test.ts +++ b/packages/web3-core/test/unit/web3_context.test.ts @@ -69,6 +69,26 @@ describe('Web3Context', () => { it('should return correct context object', () => { const context = new Context1('http://test/abc'); + // The following is because a specific property is different in node 18 than it is in node 20 and 21 + // So the problematic property is removed from the object and then added to ensure its presence and its location + // And the snapshot is updated to reflect the change. + // Once node 18 is no longer supported, this can be removed. And the snapshot need to be updated then. + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const symbolForShapeMode = Object.getOwnPropertySymbols( + (context.getContextObject().requestManager as any)._emitter, + ).find(s => s.description === 'shapeMode'); + if (symbolForShapeMode) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete (context.getContextObject().requestManager as any)._emitter[symbolForShapeMode]; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (context.getContextObject().requestManager as any)._emitter = { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ...(context.getContextObject().requestManager as any)._emitter, + [Symbol.for('shapeMode')]: false, + }; + expect(context.getContextObject()).toMatchSnapshot(); }); });