mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
feat: add mocks for isolated-vm and whois-json modules in Jest configuration
This commit is contained in:
57
Probe/Tests/__mocks__/isolated-vm.ts
Normal file
57
Probe/Tests/__mocks__/isolated-vm.ts
Normal file
@@ -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<Context> {
|
||||
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<unknown> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class Reference {
|
||||
public async set(_key: string, _value: unknown): Promise<void> {
|
||||
return;
|
||||
}
|
||||
public derefInto(): unknown {
|
||||
return {};
|
||||
}
|
||||
public applySync(
|
||||
_receiver: unknown,
|
||||
_args: unknown[],
|
||||
): unknown {
|
||||
return undefined;
|
||||
}
|
||||
public applySyncPromise(
|
||||
_receiver: unknown,
|
||||
_args: unknown[],
|
||||
): Promise<unknown> {
|
||||
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,
|
||||
};
|
||||
6
Probe/Tests/__mocks__/whois-json.ts
Normal file
6
Probe/Tests/__mocks__/whois-json.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Mock for whois-json ESM module (not parseable by Jest)
|
||||
const whoisJson = async (_domain: string): Promise<Record<string, unknown>> => {
|
||||
return {};
|
||||
};
|
||||
|
||||
export default whoisJson;
|
||||
@@ -12,6 +12,10 @@
|
||||
"babelConfig": false
|
||||
}
|
||||
},
|
||||
"moduleNameMapper": {
|
||||
"isolated-vm": "<rootDir>/Tests/__mocks__/isolated-vm.ts",
|
||||
"whois-json": "<rootDir>/Tests/__mocks__/whois-json.ts"
|
||||
},
|
||||
"moduleFileExtensions": ["ts", "js", "json"],
|
||||
"transform": {
|
||||
".(ts|tsx)": "ts-jest"
|
||||
|
||||
Reference in New Issue
Block a user