From 38c66279999325b850c595f7dedd4f5be188cd80 Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Fri, 12 Jul 2019 03:09:57 -0300 Subject: [PATCH] rewire workaround for NodeJS 12 (#774) * rewire workaround for NodeJS 12 * additional comment with a link to the underlying issue in jhnns/rewire#167 --- spec/unit/run.spec.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/unit/run.spec.js b/spec/unit/run.spec.js index 836b5b2b..406f25b9 100644 --- a/spec/unit/run.spec.js +++ b/spec/unit/run.spec.js @@ -202,8 +202,15 @@ describe('run', () => { it('should print out usage and help', () => { const logSpy = jasmine.createSpy(); const errorSpy = jasmine.createSpy(); - const procStub = { exit: _ => null, cwd: _ => '', argv: ['', ''] }; - run.__set__({ console: { log: logSpy, error: errorSpy }, process: procStub }); + run.__set__({ console: { log: logSpy, error: errorSpy } }); + + // Rewiring the process object in entirety does not work on NodeJS 12. + // Rewiring members of process however does work + // https://github.com/apache/cordova-android/issues/768 + // https://github.com/jhnns/rewire/issues/167 + run.__set__('process.exit', _ => null); + run.__set__('process.cwd', _ => ''); + run.__set__('process.argv', ['', '']); run.help(); expect(logSpy).toHaveBeenCalledWith(jasmine.stringMatching(/^Usage:/));