Coder Social home page Coder Social logo

Comments (2)

Hargne avatar Hargne commented on May 26, 2024

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.

from jest-html-reporter.

Hargne avatar Hargne commented on May 26, 2024

Closing this for now

from jest-html-reporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.