rewire workaround for NodeJS 12 (#774)

* rewire workaround for NodeJS 12

* additional comment with a link to the underlying issue in jhnns/rewire#167
This commit is contained in:
Norman Breau 2019-07-12 03:09:57 -03:00 committed by Chris Brody
parent 4b9e18c6b8
commit 38c6627999

View File

@ -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:/));