Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastify-cli: print log messages during test #546

Open
mccare opened this issue Sep 3, 2022 · 1 comment
Open

fastify-cli: print log messages during test #546

mccare opened this issue Sep 3, 2022 · 1 comment
Labels
good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor

Comments

@mccare
Copy link
Contributor

mccare commented Sep 3, 2022

You have already researched for similar issues?

Yes, nothing found

What are you trying to achieve, or the steps to reproduce?

I'm trying to see the fastify.log statements that get printed during my test. This only seems possible if fastify is logging to stderr instead of stdout (where it is swallowed by tap). I'm trying to instantiate a custom logger by using the build method of
the helper from fastify-cli:

test("default root route", async (t) => {
  const app = await build({
    logger: {
      transport: {
        target: 'pino-pretty',
        options: {
          colorize: true,
          destination: 2,
        },
      },
    });
  const res = await app.inject({
    url: "/processor",
  });
  t.same(JSON.parse(res.payload), { root: true });
});

If I pass the configuration block to Fastify(...) and build the server myself, it will instantiate the logger correctly.

What was the result you received?

The log was still to stdout and tap swallowed it.

What did you expect?

I would expect fastify to log to stderr and show the messages during a npm run test

Context

  • node version: 16.16.17
  • fastify version: >= 5.3.0
  • os: Mac
  • any other relevant information:

I can create a demo repo if that helps?

@mcollina mcollina transferred this issue from fastify/help Sep 3, 2022
@mcollina
Copy link
Member

mcollina commented Sep 3, 2022

Thanks for reporting! This is currently not supported by fastify-cli. Would you like to send a Pull Request?

@mcollina mcollina added good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor labels Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

No branches or pull requests

2 participants