Because there's no documented way to abort tests if setup in beforeAll fails (#6695), I tried to process.exit(). This works, but it turns out it's impossible to log any errors (which had lead to the setup failing).
Run this test with or without circus:
beforeAll(() => {
if ('something failed') {
const e = 'here is the error message that is not logged';
console.error('Error:', e);
process.exit(1);
}
});
test('your test suite must contain at least one test', () => {
});
I expect the console.error output to be visible in the terminal. Instead, I see this:

This is expected behaviour. You call process.exit, so it exits. Not sure if it makes sense for us to try to do any more work here.
Seems like we might have a bug with failing lifecycle hooks though, need to investigate
This is expected behaviour. You call
process.exit, so it exits. Not sure if it makes sense for us to try to do any more work here.
Not sure this answers the original issue. The issue is that, as a developer, I would expect that console.error displays the message to the console before the process exits. Is that not expected behavior?
@brandonchinn178: thanks for reviving this. I'm not super familiar with Node buffering and internals, but it seems there's generally a problem with logging anything before process.exit(). See for example this bug in Winston and this one in the Bristol logger.
Most helpful comment
Not sure this answers the original issue. The issue is that, as a developer, I would expect that
console.errordisplays the message to the console before the process exits. Is that not expected behavior?