agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
27 lines (22 loc) • 609 B
JavaScript
/**
* @file Check if file is a test file
* @description Single responsibility: Determine if a file is a test file
*/
function isTestFile(filePath, content) {
const patterns = [
/\.test\./i,
/\.spec\./i,
/__tests__/,
/test\//,
/tests\//,
/spec\//
];
if (patterns.some(pattern => pattern.test(filePath))) return true;
// Content-based detection
if (content) {
const testKeywords = ['describe(', 'it(', 'test(', 'beforeEach(', 'afterEach('];
return testKeywords.some(keyword => content.includes(keyword));
}
return false;
}
module.exports = isTestFile;