agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
58 lines (52 loc) • 1.85 kB
JavaScript
/**
* @file Unit tests for localVars module
* @description Tests local variables configuration module
*/
// Use qtests setup for consistent testing environment
const { testHelpers, createAssertions } = require('qtests');
const mod = require('./localVars.js');
/**
* qtests test suite for localVars
*/
function getTestSuite() {
const assert = createAssertions();
return {
'Local variables module loads correctly': async () => {
await testHelpers.withSavedEnv(async () => {
// Verify main configurations are exported
assert.truthy(mod.NODE_ENV !== undefined, 'NODE_ENV should be exported');
assert.truthy(mod.DEFAULT_ERROR_MESSAGE !== undefined, 'DEFAULT_ERROR_MESSAGE should be exported');
assert.truthy(mod.ERROR_CONTEXT_FORMATSTRING !== undefined, 'ERROR_CONTEXT_FORMATSTRING should be exported');
assert.truthy(mod.TEST_SUCCESS_MESSAGE !== undefined, 'TEST_SUCCESS_MESSAGE should be exported');
assert.truthy(mod.TEST_FAILURE_MESSAGE !== undefined, 'TEST_FAILURE_MESSAGE should be exported');
});
}
};
}
module.exports = { getTestSuite };
// Auto-execute when run directly (for qtests-runner compatibility)
if (require.main === module) {
(async () => {
const testSuite = getTestSuite();
let passed = 0;
let failed = 0;
for (const [testName, testFn] of Object.entries(testSuite)) {
try {
await testFn();
console.log(`✓ ${testName}`);
passed++;
} catch (error) {
console.log(`✗ ${testName}`);
console.error(`Error: ${error.message}`);
failed++;
}
}
if (failed > 0) {
console.log(`\nSummary: ${passed} passed, ${failed} failed`);
process.exit(1);
} else {
console.log(`\nSummary: ${passed} passed`);
process.exit(0);
}
})();
}