nest-commander icon indicating copy to clipboard operation
nest-commander copied to clipboard

Add an option to turn off logging in testing

Open vladkrasn opened this issue 1 year ago • 3 comments

Is there an existing issue that is already proposing this?

  • [x] I have searched the existing issues

Is your feature request related to a problem? Please describe it

I see that here logger is explicitly turned off.

export interface CommanderOptionsType
  extends Omit<CommandFactoryRunOptions, 'logger'> {
  pluginsAvailable?: boolean;
}

Though it would be really nice if, at least in testing, we could set logger: false so that unneeded lines won't spawn

Describe the solution you'd like

If logger variable was hidden for a reason, maybe there's an option to pass false to it still? Or come up with another variable?

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Would be nice to write tests with expected errors that don't clog the console

vladkrasn avatar Jan 17 '25 08:01 vladkrasn

Apologies for the delay in response. So funny enough, it's turned off so that it can be set to false inside of the CommandFactory. I'm guessing I may have forgotten that within the context of the test factory, that or something else is happening. I'll take a look at it here soon

jmcdo29 avatar Mar 13 '25 02:03 jmcdo29

Can you provide a reproduction of this happening? I'm not seeing it do that in the tests of the repository

jmcdo29 avatar Mar 14 '25 19:03 jmcdo29

Ugh, so I've been writing this example Image

But now I have a problem where turning off logger in test Fastify application doesn't work, the logs are still being generated, and I can't figure out why it works with the real project I had been working on in January, and does not here.

Now I'm not even sure if I'm even supposed to handle logger like this in tests, and if this issue has any point.

vladkrasn avatar Mar 15 '25 07:03 vladkrasn