@@ -615,37 +615,119 @@ module.exports = function (config) {
615615 });
616616};
617617```
618- ### Issue 6: Chrome Headless Timeout - "Disconnected, because no message in 30000 ms"
618+ ### Issue 6: Chrome Headless Timeout - "Disconnected, because no message in 60000 ms"
619619
620620** Error messages:**
621621```
622622Chrome Headless 140.0.0.0 (Linux 0.0.0) ERROR
623- Disconnected , because no message in 30000 ms.
623+ Disconnected , because no message in 60000 ms.
624624Error: Process completed with exit code 1.
625625```
626626
627- ** Cause:** Tests are taking longer than 30 seconds to compile or load, causing Karma to disconnect the browser. This commonly happens when:
628- - Tests include many dependencies or large files
629- - Initial compilation takes too long in CI environment
627+ ** Cause:** The browser connects but tests never execute, usually indicating:
628+ - Compilation errors in test files preventing execution
629+ - Missing dependencies or circular imports
630+ - Test setup errors that halt initialization
630631- Memory/CPU constraints in the CI environment
631632
632- ** Solution - Option A: Increase Browser Timeout (Recommended)**
633+ ** Solution - Option A: Enable Verbose Logging (Recommended First Step)**
634+
635+ To diagnose what's preventing tests from executing, enable detailed logging:
636+
637+ ** 1. Update package.json:**
638+ ``` json
639+ {
640+ "scripts" : {
641+ "test:ci" : " ng test --no-watch --browsers=ChromeHeadless --code-coverage --include='**/time-planning-pn/**/*.spec.ts' --source-map"
642+ }
643+ }
644+ ```
645+
646+ ** 2. Update karma.conf.js:**
647+ ``` javascript
648+ module .exports = function (config ) {
649+ config .set ({
650+ basePath: ' ' ,
651+ frameworks: [' jasmine' , ' @angular-devkit/build-angular' ],
652+ plugins: [
653+ require (' karma-jasmine' ),
654+ require (' karma-chrome-launcher' ),
655+ require (' karma-jasmine-html-reporter' ),
656+ require (' karma-coverage' ),
657+ require (' @angular-devkit/build-angular/plugins/karma' )
658+ ],
659+ client: {
660+ captureConsole: true , // Capture all console output
661+ clearContext: false , // Keep Jasmine Spec Runner output visible
662+ jasmine: {
663+ random: false // Run tests in deterministic order for debugging
664+ }
665+ },
666+ jasmineHtmlReporter: {
667+ suppressAll: false // Show all test output, not just failures
668+ },
669+ logLevel: config .LOG_DEBUG , // Enable detailed Karma logging
670+ browserNoActivityTimeout: 120000 , // 2 minutes to allow for debugging
671+ browserDisconnectTimeout: 10000 ,
672+ browserDisconnectTolerance: 3 ,
673+ captureTimeout: 210000 ,
674+ // ... rest of config
675+ });
676+ };
677+ ```
678+
679+ ** What verbose logging shows:**
680+ - Which test files are being loaded
681+ - Compilation progress and any errors
682+ - Console output from the test runner
683+ - Detailed timing information
684+ - Any uncaught exceptions or initialization errors
685+
686+ ** Debugging Steps:**
687+
688+ 1 . ** Run locally with verbose output:**
689+ ``` bash
690+ cd eform-client
691+ ng test --no-watch --browsers=ChromeHeadless --source-map
692+ ```
693+
694+ 2 . ** Test a single spec file to isolate the issue:**
695+ ``` bash
696+ ng test --no-watch --include=' **/time-plannings-container.component.spec.ts'
697+ ```
698+
699+ 3 . ** Check for compilation errors:**
700+ - Look for TypeScript errors in the test output
701+ - Verify all imports are correct
702+ - Ensure all test dependencies are mocked
703+
704+ 4 . ** Common causes:**
705+ - ** Import errors:** Missing or circular imports in spec files
706+ - ** Missing mocks:** Services/dependencies not properly mocked in TestBed
707+ - ** Module configuration:** Incorrect TestBed.configureTestingModule setup
708+ - ** Memory issues:** Too many test files loaded at once
709+
710+ ** Solution - Option B: Increase Browser Timeout**
711+
712+ ** Solution - Option B: Increase Browser Timeout (If tests are just slow)**
633713
634714Update ` karma.conf.js ` to increase the timeout values:
635715
636716``` javascript
637717module .exports = function (config ) {
638718 config .set ({
639719 // ... other config
640- browserNoActivityTimeout: 60000 , // Increase from default 30s to 60s
720+ browserNoActivityTimeout: 120000 , // Increase to 2 minutes
641721 browserDisconnectTimeout: 10000 ,
642722 browserDisconnectTolerance: 3 ,
643723 captureTimeout: 210000 ,
644724 });
645725};
646726```
647727
648- ** Solution - Option B: Add Chrome Flags for CI**
728+ ** Solution - Option C: Add Chrome Flags for CI**
729+
730+ ** Solution - Option C: Add Chrome Flags for CI**
649731
650732Update ` karma.conf.js ` to add Chrome flags that improve performance in CI:
651733
@@ -666,7 +748,7 @@ module.exports = function (config) {
666748 }
667749 },
668750 browsers: [' ChromeHeadlessCI' ],
669- browserNoActivityTimeout: 60000 ,
751+ browserNoActivityTimeout: 120000 ,
670752 });
671753};
672754```
@@ -681,7 +763,9 @@ Then update package.json to use this custom launcher:
681763}
682764```
683765
684- ** Solution - Option C: Optimize Test Configuration**
766+ ** Solution - Option D: Optimize Test Configuration**
767+
768+ ** Solution - Option D: Optimize Test Configuration**
685769
686770In ` angular.json ` , ensure optimization is disabled for tests:
687771
@@ -705,7 +789,9 @@ In `angular.json`, ensure optimization is disabled for tests:
705789}
706790```
707791
708- ** Solution - Option D: Use Single Quotes for Glob Pattern**
792+ ** Solution - Option E: Use Single Quotes for Glob Pattern**
793+
794+ ** Solution - Option E: Use Single Quotes for Glob Pattern**
709795
710796Make sure the test: ci script uses single quotes around the glob pattern:
711797
@@ -717,9 +803,9 @@ Make sure the test:ci script uses single quotes around the glob pattern:
717803}
718804```
719805
720- ** Combined Recommended Configuration:**
806+ ** Combined Recommended Configuration for Debugging :**
721807
722- For the best results in CI environments, combine multiple solutions in ` karma.conf.js ` :
808+ For the best results when diagnosing timeout issues, use this comprehensive ` karma.conf.js ` :
723809
724810``` javascript
725811module .exports = function (config ) {
@@ -734,26 +820,30 @@ module.exports = function (config) {
734820 require (' @angular-devkit/build-angular/plugins/karma' )
735821 ],
736822 client: {
737- jasmine: {},
738- clearContext: false
823+ captureConsole: true , // Capture console output for debugging
824+ clearContext: false , // Keep test runner output visible
825+ jasmine: {
826+ random: false // Deterministic test order
827+ }
739828 },
740829 jasmineHtmlReporter: {
741- suppressAll: true
830+ suppressAll: false // Show all output when debugging
742831 },
743832 coverageReporter: {
744833 dir: require (' path' ).join (__dirname , ' ./coverage' ),
745834 subdir: ' .' ,
746835 reporters: [
747836 { type: ' html' },
748- { type: ' text-summary' }
837+ { type: ' text-summary' },
838+ { type: ' lcovonly' }
749839 ]
750840 },
751841 reporters: [' progress' , ' kjhtml' , ' coverage' ],
752842 port: 9876 ,
753843 colors: true ,
754- logLevel: config .LOG_INFO ,
755- autoWatch: true ,
756- browsers: [' Chrome ' ],
844+ logLevel: config .LOG_DEBUG , // Verbose logging
845+ autoWatch: false ,
846+ browsers: [' ChromeHeadlessCI ' ],
757847 customLaunchers: {
758848 ChromeHeadlessCI: {
759849 base: ' ChromeHeadless' ,
@@ -766,16 +856,25 @@ module.exports = function (config) {
766856 ]
767857 }
768858 },
769- singleRun: false ,
770- restartOnFileChange: true ,
771- browserNoActivityTimeout: 60000 ,
859+ singleRun: true ,
860+ restartOnFileChange: false ,
861+ browserNoActivityTimeout: 120000 , // 2 minutes
772862 browserDisconnectTimeout: 10000 ,
773863 browserDisconnectTolerance: 3 ,
774864 captureTimeout: 210000 ,
775865 });
776866};
777867```
778868
869+ This configuration provides:
870+ - Verbose logging to see what's happening
871+ - Extended timeouts for slow compilation
872+ - Chrome flags optimized for CI environments
873+ - Console capture for debugging test issues
874+
875+ Once you identify the issue, you can switch ` logLevel ` back to ` config.LOG_INFO ` and ` jasmineHtmlReporter.suppressAll ` to ` true ` for cleaner output.
876+
877+
779878## Contact
780879
781880If you need help configuring the tests, check:
0 commit comments