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

Feature Request: Adding Test Content to HTML #36

Closed
sembaye opened this issue Mar 8, 2018 · 2 comments
Closed

Feature Request: Adding Test Content to HTML #36

sembaye opened this issue Mar 8, 2018 · 2 comments

Comments

@sembaye
Copy link

sembaye commented Mar 8, 2018

Hi,
it would be a handy feature if we can put additional content like return value from a Server into the HTML.

example:

describe('Test', () =>  {
  test('Test', (done) => {
    app.request('192.168.210.111', (err: any, cb: any) => {
      expect(err).toBe(null);
      addContent(this, {
        title: 'Received Message',
        value: cb,
      });
      done();
    });
  });
});

In this example you would see cb below the tested line in the HTML.
I used a similar function with the packet mochawesome.

@Hargne
Copy link
Owner

Hargne commented Mar 9, 2018

I have done some investigation into this, as I believed it to be an interesting feature, and have found a few issues that might make this tricky to implement.

First off, the example you provided above would not work (not even in mochawesome) as you are using Arrow Functions.

From mochawesome documentation:

Be sure to use ES5 functions and not ES6 arrow functions when using addContext to ensure this references the test object.
-https://github.com/adamgruber/mochawesome#example

Personally I believe it's important not to tie the usage of this plugin to a certain ES-version, especially since Jest is using Arrow Functions in their documentation.

However, the biggest issue is the fact that Jest have (as far as I can see) removed the usage of this (please see jestjs/jest#3553) which means that there is no direct way of getting the test context. I have done several tests, and I cannot seem to get hold of the test data either within beforeEach, afterEach or it/test.

I was able to pass the data it by assigning the it/test to a variable which was then passed into the addContext-method. Although that would mean that users would need to change the entire structure of their tests in order for this to work, and that is not something that I am aiming for with this plugin.

If anyone has any ideas, don't hesitate to drop a line.

@Hargne
Copy link
Owner

Hargne commented Sep 24, 2018

Closing this for now

@Hargne Hargne closed this as completed Sep 24, 2018
ptabor pushed a commit to ptabor/jest-html-reporter that referenced this issue Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants