# mocha-stackdriver-reporter

> Mocha reporter to log test results with Google Cloud Logging API

Latest version **0.1.0** (published 2020-05-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install mocha-stackdriver-reporter
pnpm add mocha-stackdriver-reporter
yarn add mocha-stackdriver-reporter
bun add mocha-stackdriver-reporter
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-05-06 |
| First published | 2020-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jouni Kantola |
| Maintainers | jouni-kantola |
| Keywords | mocha, stackdriver, reporter |

## Links

- npm: https://www.npmjs.com/package/mocha-stackdriver-reporter
- Homepage: https://github.com/jouni-kantola/mocha-stackdriver-reporter
- Issues: https://github.com/jouni-kantola/mocha-stackdriver-reporter/issues
- npm.io page: https://npm.io/package/mocha-stackdriver-reporter

## Dependencies (1)

- [@google-cloud/logging](https://npm.io/package/@google-cloud/logging.md) ^7.3.0

## Recent versions

- 0.1.0 (latest) — 2020-05-06
- 0.0.2 — 2020-04-30
- 0.0.1 — 2020-04-30

## README

# Mocha Stackdriver Reporter

Mocha reporter using the Google Cloud Logging API.

![npm cit](https://github.com/jouni-kantola/mocha-stackdriver-reporter/workflows/npm%20cit/badge.svg)

## Install

`npm install mocha-stackdriver-reporter --save-dev`

## Options

- `projectId`: Google Cloud Project ID.
- `logName`: Log identifier; gets merged with `projectId` into e.g. `projects/test123/logs/my-function%2Fwith-name`. Note how last part is URL encoded. This is automatically taken care when using a `logName` with `/` in the name, e.g. `my-function/with-name`.
- `entryMetadata`: Metadata for log entries.

## CLI

Run mocha with reporter configured:

```bash
mocha --reporter mocha-stackdriver-reporter --reporter-options projectId=myGcpProjectId,logName=myLogName
```

Entry metadata can be set with environment variable `ENTRY_METADATA`:

```bash
ENTRY_METADATA='{ "resource": { "labels": { "function_name": "my-cloud-function", "project_id": "my-project-id", "region": "my-region" }, "type": "cloud_function" } }' \
mocha --reporter mocha-stackdriver-reporter --reporter-options projectId=my-project-id,logName=my-log-name
```

## Code

```javascript
const Mocha = require("mocha");
const StackdriverReporter = require("mocha-stackdriver-reporter");

const mocha = new Mocha();

mocha.reporter(StackdriverReporter, {
  projectId: "my-project-id",
  logName: "my-log-name",
  entryMetadata: {
    resource: {
      labels: {
        function_name: "my-cloud-function",
        project_id: "my-project-id",
        region: "my-region",
      },
      type: "cloud_function",
    },
  },
  alsoConsole: false, // (optional) if true, also output result to console
  onlyConsole: false, // (optional) if true, only output result to console
});
```

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