I am using default built-in logger in NestJS form simple logging during development. But when I run e2e tests there is no logger output on console. A really need this, to see what is happening when test fails. Snippet from package.json:
"test:e2e": "jest --config ./test/jest-e2e.json"
And jest-e2e.json:
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"verbose": true
}
It is possible to overwrite the logger on the chain after createTestingModule
const module_: TestingModule = await Test.createTestingModule({
...
})
.setLogger(new Logger())
.compile();
which is luckily a bit shorter than the method with app.useLogger.
This feature was added in https://github.com/nestjs/nest/pull/6071
As far as I can tell you'll have to do this for every single test setup.
I personally think this is ridiculous. Of course I need my logs when fixing my tests, including debug logs, and I want them without having to add some extra code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With