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

Adding custom reporter #29

Closed
erikkallen opened this Issue Sep 24, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@erikkallen
Copy link
Contributor

erikkallen commented Sep 24, 2018

Why this feature is required (specific use-cases will be appreciated)?

I would like to generate a pdf report based on the test results, other test tools have multiple reporters and I would like to be able to add my own.

Have you tried any other work arounds?

I have cloned and edited both the JAPA and adonis-vow repository and tried to copy and edit the list reporter that is currently the only option and I tried to activate it using the REPORTER env variable but I cannot get it to output any report (not even the default list report)

Are you willing to work on it with little guidance?

I am willing to work on this

@triage-new-issues triage-new-issues bot added the triage label Sep 24, 2018

@thetutlage

This comment has been minimized.

Copy link
Member

thetutlage commented Sep 26, 2018

Hello!

Yes, it should be 100% possible, since the underlying test runner japa does support reporters.

We just need a way to use a dynamic reporter here https://github.com/adonisjs/adonis-vow/blob/develop/src/Runner/index.js#L31

Here's the code for the existing reporter https://github.com/thetutlage/japa/blob/v1.0.6/src/Reporters/list.js, just make sure you are always referencing the tag@1.0.6 for japa, since adonis-vow uses this version and not 2.0.0.

How to approach?

I can give you some insights on same to help you create a reporter.

  1. The reporter uses the event emitter to listen for different events, which are listed here
  2. You can use these events and simply build the PDF.
  3. Make sure the reporter never throws any errors, it should simply write it's own errors to the console or where ever it makes sense.

Lemme know if you need more help

@erikkallen

This comment has been minimized.

Copy link
Contributor

erikkallen commented Sep 26, 2018

Hi @thetutlage,

Thank you for your swift answer and great framework!
I am running into trouble when trying to setup for development.
What I did was the following:

  • cloned adonis-vow repository
  • checkout version 1.0.16
  • ran yarn link in the cloned adonis-vow directory
  • ran yarn link "@adonisjs/vow" in the project to test directory
  • ran adonis test in the project to testdirectory

I then get the following error:

RuntimeException: E_INVALID_SERVICE_PROVIDER: VowProvider must extend base service provider class
> More details: https://err.sh/adonisjs/errors/E_INVALID_SERVICE_PROVIDER

The same happens if I yarn add the directory or if I use npm for linking
It does work if I use the version from npm so it looks to be something to do with the linking

@thetutlage

This comment has been minimized.

Copy link
Member

thetutlage commented Sep 26, 2018

Ahh yes, since yarn link or npm link will not use top-level modules, which means adonis-vow is using a different copy of service provider from your app.

Can you change this line https://github.com/adonisjs/adonis-vow/blob/develop/providers/VowProvider.js#L12

to const { ServiceProvider } = require.main.require('@adonisjs/fold') ?

I am not 100% sure this will work, but if you want to try

@erikkallen

This comment has been minimized.

Copy link
Contributor

erikkallen commented Sep 26, 2018

I changed the line but now it cannot find the module

Error: Cannot find module '@adonisjs/fold'

I did find the package yalc https://github.com/whitecolor/yalc which does seem to work

@thetutlage

This comment has been minimized.

Copy link
Member

thetutlage commented Sep 26, 2018

Yeah use it then. I will also try it and will recommend it as the way to go. Thanks 😄

@erikkallen erikkallen referenced this issue Sep 27, 2018

Merged

added ability to select reports dynamically #30

5 of 7 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment