seogeneratorserver/tests/_helpers/commonjs-bridge.js
StillHammer dbf1a3de8c Add technical plan for multi-format export system
Added plan.md with complete architecture for format-agnostic content generation:
- Support for Markdown, HTML, Plain Text, JSON formats
- New FormatExporter module with neutral data structure
- Integration strategy with existing ContentAssembly and ArticleStorage
- Bonus features: SEO metadata generation, readability scoring, WordPress Gutenberg format
- Implementation roadmap with 4 phases (6h total estimated)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 16:14:29 +08:00

27 lines
814 B
JavaScript

/**
* Bridge pour importer les modules CommonJS depuis les tests ES modules
*/
import { createRequire } from 'module';
import path from 'path';
const require = createRequire(import.meta.url);
const ROOT = process.cwd();
export function requireCommonJS(modulePath) {
try {
const fullPath = path.join(ROOT, 'lib', `${modulePath}.js`);
// Clear require cache pour tests fraîches
delete require.cache[require.resolve(fullPath)];
return require(fullPath);
} catch (error) {
throw new Error(`Failed to require ${modulePath}: ${error.message}`);
}
}
export function mockModule(modulePath, mockExports) {
const fullPath = path.join(ROOT, 'lib', `${modulePath}.js`);
require.cache[require.resolve(fullPath)] = {
exports: mockExports,
loaded: true
};
}