Comments (10)
@dennisgrck , fyi, the links for the documentation you provided are not working.
from mocha-junit-reporter.
@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.
@bitcoder Thanks a lot for letting me know, I've fixed the links now!
from mocha-junit-reporter.
@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.
How would that fit exactly a mocha test and a Cypress test for example?
from mocha-junit-reporter.
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.
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.
@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.
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.
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)
- When i use mocha report for cypress ,generated report is werid and can not upload for testrail HOT 1
- "TypeError: testcase.testcase[0]._attr.time.toFixed is not a function" fails CI pipelines randomly HOT 1
- Generate XML with skipped testcases HOT 3
- Publish 2.1.0 to NPM HOT 3
- Cannot read properties of undefined (reading 'testsuite') HOT 13
- "useFullSuiteTitle" is setted to true by default HOT 1
- failure message is not properly escaped HOT 3
- Can't use home directory in path of mochaFile
- Outdated Documentation
- Error when using --forbid-only in mocha
- Missing attributes for JUnit XML HOT 1
- Possible to group `<testsuite>` by filename?
- How to edit | customize test suite name in the result.xml file for mocha
- runner.on is not a function
- Gitlab not reporting stuff in the proper columns
- Uncaught TypeError: Cannot read properties of undefined (reading 'length') HOT 1
- CVE sonatype-2023-4801 - Inflight package
- Reporter option maxDiffSize is ignored
- Replace `mkdirp` with `fs.mkdirSync(path, { recursive: true })`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mocha-junit-reporter.