{"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":"python","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,"search_vec":"'1.5.0':49 'add':61 'address':58 'bug':59 'ci/cd':39 'collect':30 'comprehens':16 'current':46 'custom':42 'detail':25,34 'environ':33 'everi':54 'featur':62 'generat':14 'inform':26 'integr':37 'item':31 'json':3,7,17,66 'minor':51 'month':56 'occur':53 'outcom':29 'plugin':12,67 'provid':24 'pytest':2,6,11,63 'pytest-json-report':1,5 'releas':52 'report':4,8,18,43,65 'result':22 'system':40 'test':21,28,64 'tool':44 'use':35 'version':47","created_at":"2026-04-09T03:58:00.990633+00:00","updated_at":"2026-04-16T20:04:20.560368+00:00","problems":[{"fix":"Install the plugin using pip: `pip install pytest-json-report`","cause":"The pytest-json-report plugin is either not installed, or pytest is unable to locate and load it.","error":"pytest: error: unrecognized arguments: --json-report"},{"fix":"Use the `--json-report-file` option to specify an output file: `pytest --json-report --json-report-file=report.json`","cause":"The `--json-report` flag, when used alone, prints the JSON report to standard output; it does not automatically save it to a file.","error":"pytest --json-report not generating json file"},{"fix":"Specify a file name for the report: `pytest --json-report --json-report-file=output.json`","cause":"The `--json-report-file` option requires a file path to be provided immediately after it.","error":"pytest: error: argument --json-report-file: expected one argument"},{"fix":"Ensure that your tests complete without errors that might corrupt the report file and that no other process or output is inadvertently writing to the specified report file path.","cause":"The generated JSON report file is empty, truncated, or contains non-JSON content at the beginning, preventing a JSON parser from reading it correctly.","error":"json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/numirias/pytest-json-report","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-json-report/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-09","next_check":"2026-07-08","install_tag":null}}