Hi,

I am currently in a project where I have to migrate a large codebase from 
AngularJS 1.5 to Angular 8. I have used the downgradeModule feature of the 
ngUpgrade. Here are the specific steps I took (note that the app currently 
has a single module named “oppia”, and the directives/services are 
registered as oppia.directive(...), oppia.factory(...), etc.):


   1. 
   
   I have a main bootstrap file 
   
<https://github.com/YashJipkate/oppia/blob/ang-oppia2/core/templates/dev/head/AppInit.ts>
 
   with the Angular and AngularJS module. The bootstrapping is done in a 
   similar way as described in the Angular docs here 
   
<https://angular.io/guide/upgrade-performance#bootstrapping-with-downgrademodule>
   , 
   2. 
   
   I exported the hybridized AngularJS module using exports.moduleName = 
   oppia and imported this module in every file that requires it, using var 
   oppia = require('AppInit.ts').moduleName; 
   3. 
   
   In the karma.conf 
   
<https://github.com/YashJipkate/oppia/blob/ang-oppia2/core/tests/karma.conf.ts>,
 
   I removed the compiled JS form of the bootstrap file which was earlier 
   compiled to JS and then used in all the files.
   

I did not change the AngularJS spec files (example 
<https://github.com/YashJipkate/oppia/blob/ang-oppia2/core/templates/dev/head/pages/signup-page/signup-page.controller.spec.ts>).
 
For reference, here is the full diff 
<https://github.com/YashJipkate/oppia/pull/36/files> of the above changes. 
(The main files to look at in this diff are AppInit.ts 
<https://github.com/YashJipkate/oppia/pull/36/files#diff-28a5cd7e64bb056b188820508ebe3205>
 
and karma.conf.ts 
<https://github.com/YashJipkate/oppia/pull/36/files#diff-71b78d03ebcfa568f130069ca9d7c3b5>
.)

After these changes, I am facing OOM issues while running the existing 
Karma tests. It runs fine with a few tests but runs out of memory when more 
tests are included. I have tried to run a small number of tests (using 
fdescribe) and they seem to pass which means that the code is alright 
regarding functionality and that the issues are likely due to the 
hybridization.

I am unable to understand what is going wrong here. Here are some things I 
tried / thoughts I have:

   1. 
   
   I had earlier tried using upgradeModule instead of downgradeModule, but 
   the OOM was still there along with some additional problems.
   2. 
   
   There might be too many services/directives attached to the main 
   AngularJS module and maybe Karma is mocking the whole module again and 
   again in the tests. 
   3. 
   
   I might be doing the Karma testing incorrectly, in which case some 
   additions to the karma spec files must be missing. 
   

I would really appreciate any advice on how to resolve the above issues. In 
particular, do hypotheses (2) and (3) above hold, and if so, is there a way 
to resolve them? Also, is there any set of “best practices” that the 
Angular team would suggest while carrying out Karma tests in a hybrid App? 
This has been blocking my work for a long time, so any help would be 
greatly appreciated.

Thanks,

Yash

P.S. You can check out the branch here 
<https://github.com/YashJipkate/oppia/tree/ang-oppia2> if you like. Follow 
these steps to reproduce:

   - 
   
   After cloning the branch run bash scripts/install_prerequisites.sh (on 
   Debian/Ubuntu)
   - 
   
   Fire up the local server by bash scripts/start.sh. After that, the 
   script will open up the browser window for the site. (If it hangs after 
   webpack compilation, press Ctrl+C in the terminal and run  bash 
   scripts/start.sh again -- this is a known issue.)
   - 
   
   Run bash scripts/run_frontend_tests.sh
   - 
   
   See the OOM error.
   


-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/f00b2102-77e9-4caa-a148-1b5a0bc59f5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to