diff --git a/Probe/Tests/__mocks__/isolated-vm.ts b/Probe/Tests/__mocks__/isolated-vm.ts new file mode 100644 index 0000000000..a8952b4687 --- /dev/null +++ b/Probe/Tests/__mocks__/isolated-vm.ts @@ -0,0 +1,57 @@ +// Mock for isolated-vm native module (not loadable in Jest) +export class Isolate { + public isDisposed: boolean = false; + public async createContext(): Promise { + return new Context(); + } + public dispose(): void { + this.isDisposed = true; + } +} + +export class Context { + public global: Reference = new Reference(); + public async eval(_code: string, _options?: unknown): Promise { + return undefined; + } +} + +export class Reference { + public async set(_key: string, _value: unknown): Promise { + return; + } + public derefInto(): unknown { + return {}; + } + public applySync( + _receiver: unknown, + _args: unknown[], + ): unknown { + return undefined; + } + public applySyncPromise( + _receiver: unknown, + _args: unknown[], + ): Promise { + return Promise.resolve(undefined); + } +} + +export class Callback { + constructor(_fn: (...args: unknown[]) => void) {} +} + +export class ExternalCopy { + constructor(_value: unknown) {} + public copyInto(): unknown { + return {}; + } +} + +export default { + Isolate, + Context, + Reference, + Callback, + ExternalCopy, +}; diff --git a/Probe/Tests/__mocks__/whois-json.ts b/Probe/Tests/__mocks__/whois-json.ts new file mode 100644 index 0000000000..b89edc430e --- /dev/null +++ b/Probe/Tests/__mocks__/whois-json.ts @@ -0,0 +1,6 @@ +// Mock for whois-json ESM module (not parseable by Jest) +const whoisJson = async (_domain: string): Promise> => { + return {}; +}; + +export default whoisJson; diff --git a/Probe/jest.config.json b/Probe/jest.config.json index 4ea0f190e9..96bea5c296 100644 --- a/Probe/jest.config.json +++ b/Probe/jest.config.json @@ -12,6 +12,10 @@ "babelConfig": false } }, + "moduleNameMapper": { + "isolated-vm": "/Tests/__mocks__/isolated-vm.ts", + "whois-json": "/Tests/__mocks__/whois-json.ts" + }, "moduleFileExtensions": ["ts", "js", "json"], "transform": { ".(ts|tsx)": "ts-jest"