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

Testing: allow to stub logging #1273

Closed
gr2m opened this issue Jul 20, 2020 · 4 comments · Fixed by #1355
Closed

Testing: allow to stub logging #1273

gr2m opened this issue Jul 20, 2020 · 4 comments · Fixed by #1355

Comments

@gr2m
Copy link
Contributor

gr2m commented Jul 20, 2020

When testing as document at https://probot.github.io/docs/testing/, there is currently no way to test what has been logged in my app. Logging can a relevant outcome of webhook handler life cycle, so we should make it easy to test for it.

We could introduce a new Probot({ logger }) option which would need to be a bunyan instance.

It's possible to work around that by directly mutating the probot instance:

  const simple = require("simple-mock")

  this.probot = new Probot({
    id: 1,
    githubToken: "test"
  });

  // mock this.probot.logger.* methods
  this.probot.logger.info = simple.mock();
  this.probot.logger.child = simple.mock().returnWith(this.probot.logger);

  this.probot.load(app);

But that's not very elegant, and I wouldn't consider that a public API.

@stale
Copy link

stale bot commented Sep 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 20, 2020
@gr2m
Copy link
Contributor Author

gr2m commented Sep 20, 2020

The Probot constructor now supports a log parameter. I'll add a pull request to document how to test log output

@stale stale bot removed the wontfix label Sep 20, 2020
gr2m added a commit that referenced this issue Sep 20, 2020
@gr2m gr2m closed this as completed in #1355 Dec 8, 2020
gr2m added a commit that referenced this issue Dec 8, 2020
@github-actions
Copy link

github-actions bot commented Dec 9, 2020

🎉 This issue has been resolved in version 11.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This issue has been resolved in version 10.19.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant