Code Monkey home page Code Monkey logo

mochawesome-json-to-md's Introduction

mochawesome-json-to-md

GitHub license GitHub issues GitHub stars

Overview

This tool converts JSON reports generated by mochawesome (including reports merged by mochawesome-merge) into editable markdown format. It provides flexibility by allowing users to create and customize their own markdown templates.

Table of Contents

Features

  • Convert mochawesome JSON reports to markdown format.
  • Customize the output using templates.

How do I get started?

Install package

npm install -g mochawesome-json-to-md

run the script

mochawesome-json-to-md -p ./your/file/path.json -o ./generated.md

that's it! You've successfuly converted json report to slick md report.

Script arguments

Option Alias Description Required Default
--path -p Path to the JSON report Yes
--output -o Path to the output markdown file No ./md-reports/output.md
--template -t Path to the markdown template file No ./sample-template.md
--title -T Title for the report No Test Report
--verbose -v Verbose mode No false

Templating, tags and customization

How to create a template?

You can create a template by yourself. It's just a markdown file with some tags. You can use sample-template.md as a reference. But feel free to create your own template. Below you can find all the tags and how to use them.

Singular tags

Singular tags will be replaced with the value of the tag.

Tag Description
{{title}} Title of the report
{{startDate}} Start date of the test run
{{duration}} Duration of the test run in seconds
{{totalTests}} Total number of tests
{{passedTestsCount}} Number of passed tests
{{failedTestsCount}} Number of failed tests
{{skippedTestsCount}} Number of skipped tests
{{skippedCypressTestsCount}} Number of skipped tests by Cypress
{{otherTestsCount}} Number of other tests

Block tags

Boolean tags

Boolean tags will be replaced with the content between the tags if the condition is met.

Open tag Closing tag Description
{{#passedExists}} {{/passedExists}} If there are any passed tests, then everything between these tags will be included in the report
{{#failedExists}} {{/failedExists}} If there are any failed tests, then everything between these tags will be included in the report
{{#skippedExists}} {{/skippedExists}} If there are any skipped tests, then everything between these tags will be included in the report
{{#skippedCypressExists}} {{/skippedCypressExists}} If there are any skipped tests by Cypress, then everything between these tags will be included in the report

Loop tags

Loop tags will be replaced with the content between the tags for each test with given status.

Open tag Closing tag Description
{{#passedTests}} {{/passedTests}} Everything between these tags will be included in the report for each passed test
{{#failedTests}} {{/failedTests}} Everything between these tags will be included in the report for each failed test
{{#skippedTests}} {{/skippedTests}} Everything between these tags will be included in the report for each skipped test
{{#skippedCypressTests}} {{/skippedCypressTests}} Everything between these tags will be included in the report for each skipped test by Cypress

Test tags

Test tags will be replaced with the value of the tag for each test with given status.

Tag Description
{{path}} Path to the test
{{title}} Title of the test
{{fullTitle}} Full title of the test
{{timedOut}} If the test timed out
{{duration}} Duration of the test in milliseconds
{{state}} State of the test
{{speed}} Speed of the test
{{pass}} If the test passed
{{fail}} If the test failed
{{pending}} If the test is pending
{{context}} Context of the test
{{code}} Code of the test (alert: it's a long string)
{{err}} Object with error information (alert: it's an object, call properties instead)
{{err.message}} Error message
{{err.estack}} Error stack
{{err.diff}} Error diff
{{uuid}} UUID of the test
{{parentUUID}} UUID of the parent test
{{isHook}} If the test is a hook
{{skipped}} If the test is skipped

Where can I get more help, if I need it?

Just write the issue. I'll try to answer as fast as possible.

How I can contribute to the project?

You can contribute to the project by opening an issue or creating a pull request.

But first, please, read the Contributing file. It contains all the rules and guidelines for the project. If you have any questions, please, ask them in the Issues section. I'll try to answer as fast as possible.

Plans and achievements for this project

  • Read and process passed arguments
  • Create function for "semi-dynamic" markdown template creation
  • Read json report
  • Grab all needed information
  • Grab all possible tests by type and store them together by type (recurrence)
  • Save markdown with created "semi-dynamic" markdown template and return there only informations passed as arguments
  • Create fully customizable markdown template with tags
  • Remove need of all arguments and depends only on customizable markdown template with tags
  • Remove need of lodash package
  • Remove/find substitute for yargs package
  • Add support for TypeScript
  • Add few samples of markdown templates to choose from
  • Add unit tests (topic started in this issue)
  • Rewrite and add more documentation
    • Readme
    • Contributing guidelines
    • Code of conduct
  • Add workflow for automated semantic versioning

License

MIT

Author

Tymoteusz 403-html StΔ™pieΕ„

mochawesome-json-to-md's People

Contributors

403-html avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

juli1 lucasbit

mochawesome-json-to-md's Issues

Add contribution file

Contribution (commits and PRs) will be based on conventional commits methodology. It may vary

Commits:

  • feat: = feature
  • ref: = refactor of something
  • bug: = fixed bug
  • misc: = changes to docs/README
  • chore: = none of above

Example feat: New option for showing diagram

PRs:

  • feat: = feature
  • bug: = fixed bug
  • misc: = changes to docs/README
  • chore = none of above
  • if it will have breaking changes for whole project (major update) it should also have BREAKING CHANGES before all. Example BREAKING CHANGES - feat: New template engine

Merging PRs

You can have as many commits as you wish but before giving for review please consider rebasing your branch to clear the commit list - so it'll leave cleaner repo after merging.

Branches names:

  • major/short-description-of-change
  • minor/short-description-of-change
  • fix/short-description-of-change

Versioning:

  • major change adds +1 to first number in version (1.0.0 -> 2.0.0)
  • minor change adds +1 to second number in version (1.0.0 -> 1.1.0)
  • fix change adds +1 to last number in version (1.0.0 -> 1.0.0)

Duration is wrong

The formula in index.js line 102 is wrong
const genDuration = showDuration
? > Duration: ${Math.round(duration / 60)}s \n
: "";

The value from the json is displayed in milliseconds, so to end up with seconds, divide by 1000 instead

Improvements

  • incorporate 10 NASA's safety rules for writing code
  • add eslint stricter rules
  • add code of conduct

Refactor script for having fully editable template, also move to TypeScript

Move to TS due to types and simple compilation.

It'll add value to the project by splitting to src and dist, also types will help keeping everything together

  • extract data from result
  • build md file from template
  • incorporate 10 NASA's safety rules for writing code
  • add eslint stricter rules
  • add code of conduct

Add eslint with the workflow for it

  • Add eslint with the workflow for it
  • Resolve any eslint related issues

It should be something easy to follow along, just core to not "break the code", so eslint:recommended will do and also

env:
   node: true

to not getting errors on node's methods.

Add tests

Task

Create Jest unit tests environment, and write tests to cover all methods happy paths (and write down matrix of each case possible, for later).

Tests JSON finals types:

  • one test report for each type of outcome
  • multiple test reports for each type of outcome
  • nested types (for each type, so like describe)

πŸŽ‰ 0.x.x is deprecated, please use 1.x.x version

🚨 Deprecation Notice

πŸŽ‰ Version 0.x.x is now deprecated!

Please upgrade to version 1.x.x for continued support and improvements. No further updates or fixes will be made to the 0.x.x series, and future development will focus exclusively on the 1.x.x version.

Thank you for your understanding and continued support by using it!

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.