Coder Social home page Coder Social logo

Comments (10)

bitcoder avatar bitcoder commented on September 28, 2024 1

@dennisgrck , fyi, the links for the documentation you provided are not working.

from mocha-junit-reporter.

clayreimann avatar clayreimann commented on September 28, 2024 1

@dennisgrck Sorry for the delay, I'd be happy to review a PR if you were to implement this feature. As long as nothing breaks most any contribution is welcome here

from mocha-junit-reporter.

dennisgrck avatar dennisgrck commented on September 28, 2024

@bitcoder Thanks a lot for letting me know, I've fixed the links now!

from mocha-junit-reporter.

dennisgrck avatar dennisgrck commented on September 28, 2024

@michaelleeallen @clayreimann I would be happy to implement this and prepare a PR if you think this would be interesting to review. I would make sure this is a completely tool-agnostic implementation and follows the conventions of other tools that already support this (such as pytest and various other frameworks).

IMO a tool-agnostic way to include test case properties in the resulting XML file will allow many developers to build better integrations with Mocha & various reporting, CI & testing tools that support test case properties already.

from mocha-junit-reporter.

bitcoder avatar bitcoder commented on September 28, 2024

How would that fit exactly a mocha test and a Cypress test for example?

from mocha-junit-reporter.

dennisgrck avatar dennisgrck commented on September 28, 2024

The proposed API would work exactly like the existing APIs such as this.test.attachments and this.test.consoleOutputs, so it would fit well with Mocha and Cypress like the existing approach. Hope this clarifies it!

from mocha-junit-reporter.

bitcoder avatar bitcoder commented on September 28, 2024

Well, not totally :)
How would you specify those right from the specification block (i.e., it/describe)? Not from within it. Because some metadata must be specified before and not during the test

from mocha-junit-reporter.

dennisgrck avatar dennisgrck commented on September 28, 2024

@bitcoder This is not the intention of this issue request and not in the scope of what I suggested. My suggestion (and possible PR) is to provide a simple API to specify properties, just like the existing attachment & output APIs. I don't think it's a good idea to extend the function signature for this and this is also not really necessary for my suggestion; any property that can be specified in the function signature can also be specified within the test instead, which works just like the existing APIs. Hope this clarifies it!

from mocha-junit-reporter.

dennisgrck avatar dennisgrck commented on September 28, 2024

To add some additional information to this request, other popular testing tools such as Pytest and Playwright also support test case properties the same way as the above suggestion, and they also support multiple properties with the same name. Here is an example for Playwright (which uses Playwright's annotations API):

test('user profile', async ({ page }) => {
  test.info().annotations.push({ type: 'severity', description: 'critical' });
  test.info().annotations.push({ type: 'language', description: 'english' });

  // Playwright also supports multiple properties with the same name
  test.info().annotations.push({ type: 'step', description: 'The first step' });
  test.info().annotations.push({ type: 'step', description: 'The second step' });
  test.info().annotations.push({ type: 'step', description: 'The third step' });

  // [..]
});

And here is the same example for Python & Pytest:

def test_function(record_property):
    record_property("severity", "critical")
    record_property("language", "english")
  
    # Pytest also supports multiple properties with the same name
    record_property("step", "The first step")
    record_property("step", "The second step")
    record_property("step", "The third step")

    assert True

Instead of using a tool-specific implementation like #153 from one vendor, I would like to suggest using a similar open API for this project. The mocha-junit-reporter package is used with many frameworks and tools, and it is difficult to change APIs later, so I think it would be important to implement this in a more generic way so users can use this with any tool in the future.

from mocha-junit-reporter.

dennisgrck avatar dennisgrck commented on September 28, 2024

Sounds good, I will work on this and will try to get the PR ready in the next days.

from mocha-junit-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.