{"id":1668,"library":"pytest-json-report","title":"pytest-json-report","description":"pytest-json-report is a pytest plugin that generates a comprehensive JSON report of your test results. It provides detailed information on test outcomes, collected items, and environment details, useful for integration with CI/CD systems or custom reporting tools. The current version is 1.5.0, with minor releases occurring every few months to address bugs and add features.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/numirias/pytest-json-report","tags":["pytest","testing","reporting","json","plugin"],"install":[{"cmd":"pip install pytest-json-report","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core testing framework; this library is a plugin for pytest.","package":"pytest","optional":false}],"imports":[],"quickstart":{"code":"import pytest\nimport json\nimport os\n\ndef test_success():\n    assert True\n\ndef test_failure():\n    assert False\n\n@pytest.mark.skip(reason=\"demonstrating skip\")\ndef test_skipped():\n    pass\n\ndef test_record_property(record_property):\n    record_property(\"my_custom_key\", \"my_custom_value\")\n    assert True\n\n# Run pytest and generate report.json\n# os.system('pytest --json-report') would run it, but for a quickstart example, we'll demonstrate the command.\nprint(\"To run this example, save it as `test_example.py` and run:\")\nprint(\"pytest --json-report\")\nprint(\"Then inspect the generated `report.json` file.\")\n\n# Example of reading the report (would typically be in a separate script or CI/CD)\n# if os.path.exists('report.json'):\n#     with open('report.json', 'r') as f:\n#         report_data = json.load(f)\n#     print(json.dumps(report_data['summary'], indent=2))\n","lang":"python","description":"Create a `test_example.py` file with some tests, then run `pytest --json-report` from your terminal. This command will execute your tests and generate a `report.json` file in your current working directory containing the test results and a summary."},"warnings":[{"fix":"Ensure your project uses Python 3.7-3.10 and pytest 3.7-7.0 to use pytest-json-report v1.5.0 and newer.","message":"Python 2.x support was dropped in v1.2.4. Python 3.7+ is now required. As of v1.5.0, supported Python versions are 3.7 - 3.10, and pytest versions 3.7 - 7.0.","severity":"breaking","affected_versions":"<1.2.4 (for Python 2.x users), <1.5.0 (for users on newer Python/pytest versions not yet officially supported)"},{"fix":"Always include `--json-report` when running pytest or configure it in `pytest.ini`.","message":"The plugin does not activate automatically. You must explicitly enable it via the command line with `--json-report` or by adding `addopts = --json-report` to your `pytest.ini` configuration file.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If parsing reports from older versions, be aware that `collected` and `deselected` counts might be missing or inaccurate. Update to v1.5.0 or newer for the most accurate and complete summary data.","message":"The structure and content of the JSON report, particularly the `summary` and `collected` counts, have evolved. Specifically, the `collected` count was fixed in v1.5.0 to accurately reflect all items, and the `deselected` count was added to the summary in v1.5.0 (and to collector result in v1.2.0).","severity":"gotcha","affected_versions":"<1.5.0"},{"fix":"Use `--json-report-file=/path/to/your/report.json` to specify the output path. Use `--json-report-verbosity=0|1|2` (since v1.4.0) to control terminal output verbosity (0=silent, 1=summary only, 2=verbose).","message":"By default, the report is saved as `report.json` in the current working directory. To customize the output file path or control terminal verbosity, use specific command-line options.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}