esm: add back `globalPreload` tests
This started as a revert of 938341ac.
#44710 removed setImportMetaCallback
, removing possibility for hooks authors to modify the import.meta
object. It also removed all hooks execution when node entry point was not a file (e.g. REPL, --eval
, etc.) which was not a problem except for globalPreload
which is always supposed to run. I've added some tests to ensure globalPreload
behaves correctly in this case.
I've also added back the test that was removed in https://github.com/nodejs/node/pull/46402 because it's good test for globalPreload
and ensures mocking works – which is a very important use case for hooks IMO.
Refs: https://github.com/nodejs/node/pull/46402 Fixes: https://github.com/nodejs/node/issues/48778 Fixes: https://github.com/nodejs/node/issues/48516