Rewrite brittle test to more resilient, ignoring FORCE_COLOR (#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:
41eb6e2b12/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.
This commit is contained in:
Alex Szabo 2024-07-05 05:26:03 +02:00 committed by GitHub
parent 668b6d2b41
commit 05443dc383
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -122,31 +122,17 @@ describe('#run$', () => {
it('starts the dev server with the right options', () => { it('starts the dev server with the right options', () => {
run(new DevServer(defaultOptions)).unsubscribe(); run(new DevServer(defaultOptions)).unsubscribe();
expect(execa.node.mock.calls).toMatchInlineSnapshot(` expect(execa.node.mock.calls).toBeDefined();
Array [
Array [ const [scriptName, scriptArgs, execaOptions] = execa.node.mock.calls[0];
"some/script",
Array [ expect(scriptName).toBe('some/script');
"foo", expect(scriptArgs).toEqual(['foo', 'bar', '--logging.json=false']);
"bar", expect(execaOptions).toMatchObject({
"--logging.json=false", env: expect.objectContaining({ ELASTIC_APM_SERVICE_NAME: 'kibana', isDevCliChild: 'true' }),
], nodeOptions: ['--inheritted', '--exec', '--argv'],
Object { stdio: 'pipe',
"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', () => { it('writes stdout and stderr lines to logger', () => {