elections-cpl.api.hscc.bdpa.org • Docs
elections-cpl.api.hscc.bdpa.org / test/setup / protectedImport
protectedImport<
T
>(__namedParameters
):Promise
<T
>
While isolatedImport
performs a module import as if it were being
imported for the first time, protectedImport
wraps isolatedImport
with withMockedExit
. This makes protectedImport
useful for testing
IIFE modules such as CLI entry points an externals.
• T = unknown
• __namedParameters
• __namedParameters.expectedExitCode?: number
| "non-zero"
The code that must be passed to process.exit by the imported module. If
undefined
(default), then process.exit must not be called.
Default
undefined
• __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.
Promise
<T
>