@@ -341,6 +341,9 @@ chmod +x .git/hooks/pre-push
341341| Generic errors | 6 | -50% | 2025-10-11 |
342342| Unauthorized merge | 1 | N/A | 2025-10-15 |
343343| Cherry-pick reviews | 1 | N/A | 2025-10-16 |
344+ | Jest integration tests | 7 | -100% (fixed) | 2025-10-20 |
345+ | fs-extra deprecated | 4 | -100% (fixed) | 2025-10-20 |
346+ | logger import pattern | 2 | -100% (fixed) | 2025-10-20 |
344347
345348** Objetivo:** Reducir tasa de repetición <10% en todos los patrones
346349
@@ -534,6 +537,82 @@ try {
534537
535538---
536539
540+ ### 10. fs-extra Deprecated Methods & Logger Import Patterns
541+
542+ ** Pattern:** Tests failing with "fs.remove is not a function" and "logger.info is not a function" due to incorrect library usage and import patterns.
543+
544+ ** Issue:** Test Fixing Session #2 (2025-10-20) - Fixed 6 more errors after roast.test.js success
545+
546+ ** ❌ Mistake 1: Using deprecated fs-extra methods**
547+ ``` javascript
548+ // Wrong: fs.remove() deprecated/unavailable in fs-extra 11.x
549+ const fs = require (' fs-extra' );
550+
551+ afterAll (async () => {
552+ await fs .remove (tempLogDir); // Error: fs.remove is not a function
553+ });
554+ ```
555+
556+ ** ✅ Fix:**
557+ ``` javascript
558+ // Correct: Use Node's built-in fs/promises.rm()
559+ const fs = require (' fs-extra' );
560+ const { rm } = require (' fs/promises' ); // Node built-in (Issue #618)
561+
562+ afterAll (async () => {
563+ await rm (tempLogDir, { recursive: true , force: true });
564+ });
565+ ```
566+
567+ ** ❌ Mistake 2: Logger import not matching Jest mock structure**
568+ ``` javascript
569+ // Wrong: Import entire module when tests export { logger: {...} }
570+ const logger = require (' ../utils/logger' );
571+
572+ constructor () {
573+ logger .info (' Initializing...' ); // Error: logger.info is not a function
574+ }
575+ ```
576+
577+ ** ✅ Fix:**
578+ ``` javascript
579+ // Correct: Destructure logger to match Jest mock structure
580+ const { logger } = require (' ../utils/logger' ); // Issue #618 - destructure
581+
582+ constructor () {
583+ logger .info (' Initializing...' ); // ✅ Works!
584+ }
585+ ```
586+
587+ ** Impact:**
588+ - ** Before:** 6 errors blocking multiple test suites
589+ - ** After:** fs.remove errors resolved (4), logger.info errors resolved (2)
590+ - ** Tests unblocked:** logCommands.test.js, autoApprovalSecurityV2.test.js
591+
592+ ** Files affected:**
593+ - tests/integration/cli/logCommands.test.js (fs.remove → rm)
594+ - src/services/PersonaService.js (logger import destructured)
595+
596+ ** Prevention checklist:**
597+ - [ ] Check library version supports the method you're using
598+ - [ ] Prefer Node built-ins over library methods when available
599+ - [ ] Ensure imports match Jest mock structure (destructure if mock exports object)
600+ - [ ] Test import pattern: ` const { export } = require(...) ` vs ` const export = require(...) `
601+ - [ ] Check if method exists in library changelog/docs before using
602+ - [ ] When errors say "is not a function", verify import/export pattern match
603+
604+ ** Occurrences:**
605+ - fs.remove: 4 (all in logCommands.test.js)
606+ - logger incorrect import: 2 (PersonaService.js affected multiple tests)
607+
608+ ** Last occurrence:** 2025-10-20 (Issue #618 , commit 9d4cede1)
609+
610+ ** Related patterns:**
611+ - Jest Integration Tests (#9 ) - Module-level calls need defensive checks
612+ - Testing Patterns (#2 ) - Use production code paths in tests
613+
614+ ---
615+
537616## 📚 Related Documentation
538617
539618- [ Quality Standards] ( ../QUALITY-STANDARDS.md ) - Non-negotiable requirements for merge
@@ -546,4 +625,4 @@ try {
546625** Maintained by:** Orchestrator
547626** Review Frequency:** Weekly or after significant reviews
548627** Last Reviewed:** 2025-10-20
549- ** Version:** 1.3.0
628+ ** Version:** 1.4.0 (Added pattern # 10 : fs-extra + logger imports)
0 commit comments