Skip to content

Commit

Permalink
Rewrite brittle test to more resilient, ignoring FORCE_COLOR (elastic…
Browse files Browse the repository at this point in the history
…#187539)

## Summary
We've seen the tests go both ways on the new infra. Sometimes the
received object would have, sometimes it wouldn't have `FORCE_COLOR`.
The value comes from here:
https://github.com/elastic/kibana/blob/41eb6e2b12aa23ea03c852869cfe908fd80b02bc/packages/kbn-cli-dev-mode/src/using_server_process.ts#L39
- meaning `process.stdout.isTTY` is not always true?

Here, it fails because the snapshot doesn't have the flag:
https://buildkite.com/elastic/kibana-on-merge/builds/47027#01907bbb-3fae-48c4-95ca-85118ba2c2b8
Here, it because the snapshot has the flag:
https://buildkite.com/elastic/kibana-pull-request/builds/219429

This PR tries to ignore that part of the received object.
  • Loading branch information
delanni authored and adelisle committed Aug 5, 2024
1 parent 29ef56e commit 1bc79ee
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions packages/kbn-cli-dev-mode/src/dev_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,17 @@ describe('#run$', () => {
it('starts the dev server with the right options', () => {
run(new DevServer(defaultOptions)).unsubscribe();

expect(execa.node.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"some/script",
Array [
"foo",
"bar",
"--logging.json=false",
],
Object {
"env": Object {
"<inheritted process.env>": true,
"ELASTIC_APM_SERVICE_NAME": "kibana",
"isDevCliChild": "true",
},
"nodeOptions": Array [
"--inheritted",
"--exec",
"--argv",
],
"stdio": "pipe",
},
],
]
`);
expect(execa.node.mock.calls).toBeDefined();

const [scriptName, scriptArgs, execaOptions] = execa.node.mock.calls[0];

expect(scriptName).toBe('some/script');
expect(scriptArgs).toEqual(['foo', 'bar', '--logging.json=false']);
expect(execaOptions).toMatchObject({
env: expect.objectContaining({ ELASTIC_APM_SERVICE_NAME: 'kibana', isDevCliChild: 'true' }),
nodeOptions: ['--inheritted', '--exec', '--argv'],
stdio: 'pipe',
});
});

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

0 comments on commit 1bc79ee

Please sign in to comment.