You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/11/04 13:13:56 UTC

[cordova-cli] branch master updated: Avoid registering too many event listeners in tests (#477)

This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 44afc89  Avoid registering too many event listeners in tests (#477)
44afc89 is described below

commit 44afc892ea3db41ebcff66047d41f9c6d3e74317
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Mon Nov 4 14:13:41 2019 +0100

    Avoid registering too many event listeners in tests (#477)
    
    Instead of muting the warning that Node.js displays about it.
---
 spec/cli.spec.js | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/spec/cli.spec.js b/spec/cli.spec.js
index 51bbb09..b614630 100644
--- a/spec/cli.spec.js
+++ b/spec/cli.spec.js
@@ -21,9 +21,6 @@ const { events, cordova } = require('cordova-lib');
 const telemetry = require('../src/telemetry');
 const cli = rewire('../src/cli');
 
-// avoid node complaining of too many event listener added
-process.setMaxListeners(0);
-
 describe('cordova cli', () => {
     let logger;
 
@@ -33,8 +30,9 @@ describe('cordova cli', () => {
         // logging events registered as a result of the "--verbose" flag in
         // CLI testing below would cause lots of logging messages printed out by other specs.
 
-        // This is required so that fake events chaining works (events.on('log').on('verbose')...)
-        spyOn(events, 'on').and.returnValue({ on () { return this; } });
+        // Prevent listeners from piling up
+        spyOn(process, 'on');
+        events.removeAllListeners();
 
         // Spy and mute output
         logger = jasmine.createSpyObj('logger', [


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org