Skip to content

Latest commit

 

History

History
51 lines (30 loc) · 1.35 KB

File metadata and controls

51 lines (30 loc) · 1.35 KB

elections-cpl.api.hscc.bdpa.orgDocs


elections-cpl.api.hscc.bdpa.org / test/setup / protectedImport

Function: 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.

Type parameters

T = unknown

Parameters

__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.

Returns

Promise<T>

Source

test/setup.ts:314