@kya-os/mcp-i
Version:
The TypeScript MCP framework with identity features built-in
51 lines (50 loc) • 1.43 kB
JavaScript
;
/**
* Test environment detection and configuration
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTestMode = isTestMode;
exports.getCurrentTestSeed = getCurrentTestSeed;
exports.ensureTestMode = ensureTestMode;
exports.configureTestEnvironment = configureTestEnvironment;
exports.shouldSkipKTACalls = shouldSkipKTACalls;
const test_1 = require("@kya-os/contracts/test");
/**
* Check if we're running in test mode
*/
function isTestMode() {
return (0, test_1.isTestEnvironment)();
}
/**
* Get the current test seed for deterministic key generation
*/
function getCurrentTestSeed(testName) {
return (0, test_1.getTestSeed)(testName);
}
/**
* Ensure we're in test mode, throw if not
*/
function ensureTestMode() {
if (!isTestMode()) {
throw new Error(`${test_1.TEST_ERROR_CODES.INVALID_TEST_CONFIGURATION}: Test utilities can only be used when XMCP_ENV=test`);
}
}
/**
* Configure test environment
*/
function configureTestEnvironment(options = {}) {
if (options.seed) {
process.env.XMCP_TEST_SEED = options.seed;
}
if (options.skipKTACalls !== false) {
process.env.XMCP_SKIP_KTA_CALLS = "true";
}
// Ensure we're in test mode
process.env.XMCP_ENV = "test";
}
/**
* Check if KTA calls should be skipped
*/
function shouldSkipKTACalls() {
return isTestMode() || process.env.XMCP_SKIP_KTA_CALLS === "true";
}