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

API for registering custom reporters #2583

Closed
tymfear opened this issue Sep 18, 2020 · 3 comments
Closed

API for registering custom reporters #2583

tymfear opened this issue Sep 18, 2020 · 3 comments
Labels

Comments

@tymfear
Copy link
Contributor

tymfear commented Sep 18, 2020

@novemberborn , what do you think about creating an API for custom reporters (not only reporters, probably)?
Something like an array of objects in settings, each object implements some set of functions called for each hook.

Like

class Reporter {
  onBeforeStart(t: Context);
  onBeforeEnd(t: Context);

  onBeforeEachStart(t: Context);
  onBeforeEachEnd(t: Context);

  onAssertionFailure(t: Context);
  
  onTestStart(t: Context);
  onTestEnd(t: Context);

  onAfterEachStart(t: Context);
  onAfterEachEnd(t: Context);

  onAfterStart(t: Context);
  onAfterEnd(t: Context);
}

ANd then in config file something like

const customReporter = new Reporter();

export default {
  plugins: [customReporter]
}

That would allow creating different plugins/reporters easily.

@novemberborn
Copy link
Member

When it comes to reporters I think the right approach is to output high-fidelity structured data, which can be piped to another process.

More concretely:

  • AVA would have one, awesome reporter
  • AVA emits some JSON format that captures all the detail it has available internally
  • Other CLI tools exist which can process that JSON

This is still a ways off I think.

What do you think?

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@tymfear
Copy link
Contributor Author

tymfear commented Oct 18, 2020

@novemberborn So I would like to have a hook for failed assertion to be able to take screenshots when I use browser tests. Otherwise I have to check every result before/after to have precise screenshots.

Anyway, is there an issue for that JSON report?

@novemberborn
Copy link
Member

I would like to have a hook for failed assertion to be able to take screenshots when I use browser tests. Otherwise I have to check every result before/after to have precise screenshots.

You should be able to do that with t.try() or afterEach checking for t.passed.

Anyway, is there an issue for that JSON report?

No it's just in my head I think.

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

No branches or pull requests

2 participants