#why does logger not work in test module

15 messages · Page 1 of 1 (latest)

crude oriole
#

Works fine when I use NestFactory.create but when instantiated via Test.createTestingModule it does not

ashen pilot
#

The default test logger is set to error only. You can modify this as needed. I think with modRef.useLogger? Haven't had to mess with that for a while'

unique gazelle
#

setLogger

#

setLogger
useMocker
man 😅

#

I guess I'll propose changing setLogger to useLogger for v11 😎

stray fulcrum
#

Btw it's that way so it does not pollute your unit test log. I all goes well, you ideally just want a green PASS, instead of half a page of logs between each test.

unique gazelle
ashen pilot
unique gazelle
stray fulcrum
#

By the way, as the method naming goes, I think it's alright. The useXx is used within the test module builder, that is, before .compile is called. This is pretty much a convention with the builder pattern. (That, and withXx)

The setXx, on the other hand, is used to set something on an already created object.

unique gazelle
#

a bit confusing to me tho

stray fulcrum
#

Oh wait, it's the other way around??? 🤔

unique gazelle
#

useLogger came from NestApplicationContext
setLogger came from TestingModuleBuilder