elections-cpl.api.hscc.bdpa.org • Docs
elections-cpl.api.hscc.bdpa.org / test/setup / isolatedImport
isolatedImport<
T
>(__namedParameters
):T
Performs a module import as if it were being imported for the first time.
Note that this function breaks the "require caching" expectation of Node.js modules. Problems can arise, for example, when closing an app-wide database connection in your test cleanup phase and expecting it to close for the isolated module too. In this case, the isolated module has its own isolated "app-wide" connection that would not actually be closed and could cause your test to hang unexpectedly, even when all tests pass.
• T = unknown
• __namedParameters
• __namedParameters.path: string
Path to the module to import. Module resolution is handled by require
.
• __namedParameters.useDefault?: boolean
By default, only if module.__esModule === true
, the default export will
be returned instead. Use useDefault
to override this behavior in either
direction.
T