(
moduleName: string,
moduleID: string,
context: VMContext,
)
| 1303 | } |
| 1304 | |
| 1305 | private async importMock<T = unknown>( |
| 1306 | moduleName: string, |
| 1307 | moduleID: string, |
| 1308 | context: VMContext, |
| 1309 | ): Promise<T> { |
| 1310 | if (this.registries.hasModuleMock(moduleID)) { |
| 1311 | return this.registries.getModuleMock(moduleID) as T; |
| 1312 | } |
| 1313 | |
| 1314 | const factory = this.mockState.getEsmFactory(moduleID); |
| 1315 | if (factory) { |
| 1316 | const invokedFactory = (await factory()) as Record<string, unknown>; |
| 1317 | const module = syntheticFromExports(moduleName, context, invokedFactory); |
| 1318 | this.registries.setModuleMock(moduleID, module); |
| 1319 | return evaluateSyntheticModule(module) as T; |
| 1320 | } |
| 1321 | |
| 1322 | throw new Error('Attempting to import a mock without a factory'); |
| 1323 | } |
| 1324 | |
| 1325 | private async importWasmModule( |
| 1326 | source: BufferSource, |
no test coverage detected