Skip to content

Commit

Permalink
mock process.execArgv so that it is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Nov 1, 2021
1 parent 88f9356 commit f2738b4
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions packages/kbn-cli-dev-mode/src/dev_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ expect.addSnapshotSerializer(extendedEnvSerializer);
beforeEach(() => {
jest.clearAllMocks();
log.messages.length = 0;
process.execArgv = ['--inheritted', '--exec', '--argv'];
currentProc = undefined;
});

Expand Down Expand Up @@ -123,10 +124,30 @@ describe('#run$', () => {
// ensure that FORCE_COLOR is in the env for consistency in snapshot
process.env.FORCE_COLOR = process.env.FORCE_COLOR || 'true';

const [script, args, options] = execa.node.mock.calls[0];
expect(script).toBe('some/script');
expect(args).toEqual(['foo', 'bar']);
expect(options.stdio).toEqual('pipe');
expect(execa.node.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"some/script",
Array [
"foo",
"bar",
],
Object {
"env": Object {
"<inheritted process.env>": true,
"ELASTIC_APM_SERVICE_NAME": "kibana",
"isDevCliChild": "true",
},
"nodeOptions": Array [
"--inheritted",
"--exec",
"--argv",
],
"stdio": "pipe",
},
],
]
`);
});

it('writes stdout and stderr lines to logger', () => {
Expand Down

0 comments on commit f2738b4

Please sign in to comment.