-
Notifications
You must be signed in to change notification settings - Fork 101
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
Ability to expose custom text on report page #32
Comments
Hi @4ekki , How about adding a reporter option? |
@Hazyzh , yeah, this should work. Will it handle environment variables? |
I can get environment variables, but hard to know which variables should show in the report. |
What about taking a single specific variable, smth like $JEST_HTML_REPORTERS_CUSTOM_TEXT, and exposing its value to the report, if it's defined? Such variable can be initialized in globalTeardown script, allowing me to put there anything I want. |
If so, what's structure would the value like of this variable? for a single string, it's hard to display every item one by one. |
For my specific case, I want to show this block in the report:
But I wanted to handle the formatting on my own (with all those \n and \t), since other people will definitely have their own structure. However, I can put it into a json or an array of key-value pairs and you'll be able to parse it and put into a nice table-like structure. |
env variable name is *JEST_HTML_REPORTERS_CUSTOM_INFOS* Closes #32
Hi @4ekki, A common way to use this feature is to set values in the config's |
* ✨ (main page) add a feature to display custom infos in main page env variable name is *JEST_HTML_REPORTERS_CUSTOM_INFOS* Closes #32 * Annotated * update versions
@Hazyzh , many thanks!!! |
Small note for anyone referring this in future. Since globalTeardown is actually run AFTER the report is being created, initializing JEST_HTML_REPORTERS_CUSTOM_INFOS should be done in globalSetup instead. |
@4ekki if i want to attach the test case logs at the end of each test case then, can i use this? |
@poojachoudhary13, this feature allows to define process.env.JEST_HTML_REPORTERS_CUSTOM_INFOS in globalSetup script and then read/write it in tests. On creating the report, object from this variable will be parsed to nice table in 'Custom information' section. I don't understand how do you want to attach test case logs with this. Please share additional details. |
@4ekki Ohh okay, i wanted to attach console.log for each testcase. So that in case of failure we have some logs to look for. I thought JEST_HTML_REPORTERS_CUSTOM_INFOS will help with that.IS there any way to do what i am trying to achieve ? |
@poojachoudhary13 , I don't think that you'll be able to put logs into this report. Furthermore, I don't think it's a good idea, since this report will be very huge if it contains all the logs. |
Hi, I don't seem to get the environment variable (JEST_HTML_REPORTERS_CUSTOM_INFOS).
this is how I've initialised my globalSetup.ts. |
@kewinshah25 , this property should be a stringified JSON, which needs double quotes instead of single ones. Change to It's even easier to define it as object and use JSON.stringify:
|
Thanks, that helped a lot!! |
I tried the same thing on my detox project using jest test runner . I cant see it in the reporter. But when I try to add customInfos in jest.config.js it works fine. I want to print these information on the fly to fetch the device.name and device.getPlatform() , after the app is launched in a emulator / simulator. Any idea how can I get these information printed on my reporter .. I use default globalSetup from jest and dont create my own. |
@mushtaque87 , from your Unfortunately, AFAIK there's no way to share data from tests to globalSetup in Jest. |
I run tests with multiple versions of SUT and it would be great to be able to see inside the report, what software version was actually tested.
I'd like to be able to run jest with some environment variable, that will be taken into account by jest-html-reporters and text from this variable would be added to report page, something like this:
The text was updated successfully, but these errors were encountered: