# jasmine-json-test-reporter

> Write Jasmine test results to disk in JSON format

Latest version **1.0.0-beta** (published 2015-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install jasmine-json-test-reporter
pnpm add jasmine-json-test-reporter
yarn add jasmine-json-test-reporter
bun add jasmine-json-test-reporter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta |
| Published | 2015-04-30 |
| First published | 2015-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Andrew Levine |
| Maintainers | drewml |
| Keywords | JSON, jasmine, protractor, reporter, tests |

## Links

- npm: https://www.npmjs.com/package/jasmine-json-test-reporter
- Repository: https://github.com/DrewML/jasmine-json-test-reporter
- Issues: https://github.com/DrewML/jasmine-json-test-reporter/issues
- npm.io page: https://npm.io/package/jasmine-json-test-reporter

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0-beta (latest) — 2015-04-30

## README

# jasmine-json-test-reporter

[Jasmine Custom Reporter Documentation](http://jasmine.github.io/2.1/custom_reporter.html)

## What is it?

This project is a custom [Jasmine](http://jasmine.github.io/) reporter that will output spec results, organized by suite, to a file location you specify, as JSON.

## Why?

I had a project using Jasmine/Protractor that required that I have a parsable version of the test results. The custom Jasmine reporters I could find only gave options to output to the common formats (JUnit, NUnit, TeamCity, HTML). Since I need to parse this data within JavaScript, it made sense to have a JSON representation of my test results.

Protractor does technically provide an option to export results as JSON using the `resultJsonOutputFile` option, but the data provided is limited. Additionally, I had a need to run Protractor multiple times and dynamically assign the test results output filename each time, which cannot currently be done with Protractor (config can't be modified at run-time).

## How to use

### Install
`npm install jasmine-json-test-reporter --save-dev`

### Jasmine Usage
```javascript
var JSONReporter = require('jasmine-json-test-reporter');
jasmine.getEnv().addReporter(new JSONReporter({
	file: 'jasmine-test-results.json',
	beautify: true,
	indentationLevel: 4 // used if beautify === true
}));
```

### Protractor/Jasmine Usage
```javascript
// in Protractor conf
var JSONReporter = require('jasmine-json-test-reporter');

...

framework: 'jasmine2',
onPrepare: function() {
	jasmine.getEnv().addReporter(new JSONReporter({
		file: 'jasmine-test-results.json',
		beautify: true,
		indentationLevel: 4 // used if beautify === true
	}));
}
```

## Example Output w/ Default Options

```json
{
    "suite1": {
        "id": "suite1",
        "description": "example suite",
        "fullName": "example suite",
        "failedExpectations": [],
        "status": "finished",
        "specs": [
            {
                "id": "spec0",
                "description": "should test something",
                "fullName": "example suite should test something",
                "failedExpectations": [],
                "passedExpectations": [
                    {
                        "matcherName": "toBe",
                        "message": "Passed.",
                        "stack": "",
                        "passed": true
                    },
                    {
                        "matcherName": "toBe",
                        "message": "Passed.",
                        "stack": "",
                        "passed": true
                    }
                ],
                "status": "passed"
            }
        ]
    }
}
```

---
_Source: https://npm.io/package/jasmine-json-test-reporter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
