Angular 7 Unit testing - PhantomJS has crashed

I am using Angular 7 for unit testing using karma and phantom JS. While I have run from my local machine, from my MAC --

ng test --watch=false

Local Machine Output -

ng test
10% building modules 2/2 modules 0 active18 01 2020 14:54:57.990:WARN [karma]: No captured browser, open http://localhost:9876/
18 01 2020 14:54:57.995:INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
18 01 2020 14:54:57.997:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
18 01 2020 14:54:58.011:INFO [launcher]: Starting browser PhantomJS
 10% building modules 5/7 modules 2 active ..._weather_forcast_testing/src/styles.cssBrowserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
18 01 2020 14:55:05.820:WARN [karma]: No captured browser, open http://localhost:9876/    
18 01 2020 14:55:06.004:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket i77IuK4nefa0HrxhAAAA with id 31463905
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 6 of 6 SUCCESS (1.598 secs / 1.535 secs)
TOTAL: 6 SUCCESS
TOTAL: 6 SUCCESS

It's working fine. MAC Configuration -

Angular CLI: 7.3.7
Node: 8.9.4
OS: darwin x64
Angular: 7.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.1.4
@angular-devkit/schematics        7.3.7
@angular/cdk                      7.3.6
@angular/cli                      7.3.7
@angular/flex-layout              7.0.0-beta.22
@angular/material                 7.3.6
@ngtools/webpack                  7.1.4
@schematics/angular               7.3.7
@schematics/update                0.13.7
rxjs                              6.4.0
typescript                        3.2.2
webpack                           4.23.1

I deployed the same code in AWS EC2 - Ubuntu 18.04, Try to run the same command -

ng test --watch=false

Ubuntu machine Output -

ng test
10% building modules 2/2 modules 0 active18 01 2020 09:22:29.639:WARN [karma]: No captured browser, open http://localhost:9876/
    18 01 2020 09:22:29.710:INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
    18 01 2020 09:22:29.710:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
    18 01 2020 09:22:29.831:INFO [launcher]: Starting browser PhantomJS
     10% building modules 7/10 modules 3 active ..._weather_forcast_testing/src/styles.cssBrowserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
     52% building modules 354/354 modules 0 active18 01 2020 09:23:29.869:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
     56% building modules 390/390 modules 0 active18 01 2020 09:23:34.149:INFO [launcher]: Trying to start PhantomJS again (1/2).
     95% emitting CopyPlugin                                                                  

    18 01 2020 09:24:54.635:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
    18 01 2020 09:25:24.043:WARN [karma]: No captured browser, open http://localhost:9876/
    18 01 2020 09:25:24.793:INFO [launcher]: Trying to start PhantomJS again (2/2).
    18 01 2020 09:25:25.515:ERROR [karma-server]: { Error: spawn ENOMEM

    Cannot read property 'success' of undefined
    TypeError: Cannot read property 'success' of undefined
        at TestCommand.runSingleTarget (/home/ubuntu/youtube_angular7__weather_forcast_testing/node_modules/@angular/cli/models/packages/angular/cli/models/architect-command.ts:242:21)
        at <anonymous>
        at Immediate._tickCallback (internal/process/next_tick.js:189:7)
        at runCallback (timers.js:810:20)
        at tryOnImmediate (timers.js:768:5)
        at processImmediate [as _immediateCallback] (timers.js:745:5)

Ubuntu Machine Configuration -

Angular CLI: 7.3.7
Node: 8.17.0
OS: linux x64
Angular: 7.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.1.4
@angular-devkit/schematics        7.3.7
@angular/cdk                      7.3.6
@angular/cli                      7.3.7
@angular/flex-layout              7.0.0-beta.22
@angular/material                 7.3.6
@ngtools/webpack                  7.1.4
@schematics/angular               7.3.7
@schematics/update                0.13.7
rxjs                              6.4.0
typescript                        3.2.2
webpack                           4.23.1

Why the same code and same configuration is working fine in MAC and not working in Ubuntu ?

1 answer

  • answered 2020-01-18 10:01 Atique Ahmed

    Issue resolved by adding -

    ng test --source-map=false --watch=false