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

Add option to attach screenshot #36

Closed
storralba-elsevier opened this issue Feb 19, 2020 · 11 comments · Fixed by #47
Closed

Add option to attach screenshot #36

storralba-elsevier opened this issue Feb 19, 2020 · 11 comments · Fixed by #47
Assignees
Labels
enhancement New feature or request

Comments

@storralba-elsevier
Copy link

Is your feature request related to a problem? Please describe.
The reporter is really good but I miss the option to add an screenshot or any other support file if something fails or to clarify the test report.
Describe the solution you'd like
reporter.currentTest.attach(file);
Where file an be image or text.

@storralba-elsevier storralba-elsevier added the enhancement New feature or request label Feb 19, 2020
@tomardern
Copy link

Would love this too - @Hazyzh any ideas on if/when this could/can be implemented?

@Hazyzh Hazyzh added this to the Version - (2.x) milestone Apr 8, 2020
@Hazyzh
Copy link
Owner

Hazyzh commented Apr 8, 2020

good idea! need to think more about how to implement this feature. just add this to milestone 2.x.

@Hazyzh
Copy link
Owner

Hazyzh commented Jun 13, 2020

Same as #37, this reporter just to display the data that we got form Jest, and we can not add any custom data to test results. I can provide a method to save images, but the key point is how to relate that image to the corresponding test case.

Hazyzh added a commit that referenced this issue Jun 15, 2020
@Hazyzh Hazyzh linked a pull request Jun 15, 2020 that will close this issue
@Hazyzh
Copy link
Owner

Hazyzh commented Jun 15, 2020

From Jest source code I found that there is a global variable when really running a test which stores the base information of the test. I can got file path and test full name from it, then combine it to our test result. This is a hack way that may not stable, but can not find another better way now.

@Hazyzh
Copy link
Owner

Hazyzh commented Jun 15, 2020

/**
 *
 * @param {Buffer | string} attach
 * @param {string} description
 */
const addAttach = async (attach, description) => { ... }

provide a new method 'addAttach' in the package, in the test case you can add an image attach by using this method, and those images will show in the corresponding test case.
image

will update more detail in the readme.

Hazyzh added a commit that referenced this issue Jun 15, 2020
@Hazyzh
Copy link
Owner

Hazyzh commented Jun 15, 2020

New version (2.0.0) released. You can have a try now.

@tomardern
Copy link

Amazing - great idea, thanks for providing!

@storralba-elsevier
Copy link
Author

Works perfectly! Thanks a lot!

@PEZO19
Copy link

PEZO19 commented Jul 10, 2020

Is there a way to attach html instead of a screenshot?

@Hazyzh
Copy link
Owner

Hazyzh commented Jul 12, 2020

Is there a way to attach html instead of a screenshot?

Not support currently. maybe we can support it if it is a common use case.

@fivethreeo
Copy link

This would be great, but maybe call it attachAsset and make it possible to add more than one

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

Successfully merging a pull request may close this issue.

5 participants