npm package: @joseph.adams/prism
Description: A modern test report viewer for Playwright/Allure results — no extra tooling required
Latest version: 0.9.0

# Prism

A personal project built to solve my own test reporting needs — a modern, lightweight viewer for Playwright + Allure results.

Reads directly from your `allure-results` folder — no `allure generate`, no extra pipeline steps. Run your tests, point Prism at the results, open your browser.

Published to npm purely as a convenient way to install and deploy it across my own projects. It's not intended as a general-purpose open source tool, but you're welcome to use it if it fits your needs.

---

## Installation

```bash
npm install -g @joseph.adams/prism
```

Or without installing:

```bash
npx @joseph.adams/prism --results=./allure-results
```

---

## Usage

### Local / interactive (server mode)

From your Playwright project root:

```bash
prism --results=./allure-results
```

Open `http://localhost:4999` in your browser.

| Flag               | Default            | Description                        |
| ------------------ | ------------------ | ---------------------------------- |
| `--results=<path>` | `./allure-results` | Path to your allure-results folder |
| `--port=<number>`  | `4999`             | Port to run the server on          |

### Adding to your project scripts

```json
{
  "scripts": {
    "test:login": "npx playwright test --grep \"(@login)\"",
    "report": "prism --results=./allure-results"
  }
}
```

---

## Jenkins / CI (static export mode)

For Jenkins and other CI environments, use the static export command. This generates a single self-contained `index.html` with all data, styles and scripts inlined — no server required.

```bash
prism-export --results=./allure-results --export=./prism-report
```

| Flag               | Default            | Description                            |
| ------------------ | ------------------ | -------------------------------------- |
| `--results=<path>` | `./allure-results` | Path to your allure-results folder     |
| `--export=<path>`  | `./prism-report`   | Output directory for the static report |

### Jenkins pipeline example

```groovy
pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                sh 'npm run test:login'
            }
        }
        stage('Report') {
            steps {
                sh 'npx @joseph.adams/prism-export --results=./allure-results --export=./prism-report'
            }
        }
    }
    post {
        always {
            publishHTML(target: [
                allowMissing         : false,
                alwaysLinkToLastBuild: true,
                keepAll              : true,
                reportDir            : 'prism-report',
                reportFiles          : 'index.html',
                reportName           : 'Prism Report'
            ])
        }
    }
}
```

> **Note:** Jenkins' Content Security Policy can block inline scripts. If the report shows a blank page, add this to your Jenkins script console:
>
> ```groovy
> System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
> ```
>
> Or configure it via the Jenkins administation panel under Script Console.

---

## Theming

Prism resolves the theme file in the following order — the first file found wins:

1. **`prism-theme.json` in your current working directory** — project-level override. Drop this in your Playwright project root to customise per-project.
2. **`~/.prism/prism-theme.json`** — user-level default. Set this once and all projects inherit it unless overridden.
3. **Built-in default theme** — always present as a fallback. Light theme, indigo accent.

Prism logs which theme file it is using on startup.

### Theme file format

```json
{
  "reportTitle": "My Project",
  "defaultTheme": "light",
  "allowThemeToggle": true,
  "colors": {
    "light": {
      "passed": "#22c55e",
      "failed": "#ef4444",
      "broken": "#f97316",
      "skipped": "#94a3b8",
      "unknown": "#64748b",
      "accent": "#6366f1",
      "background": "#f8fafc",
      "surface": "#ffffff",
      "surface2": "#f1f5f9",
      "text": "#0f172a",
      "textMuted": "#64748b",
      "border": "#e2e8f0"
    },
    "dark": {
      "passed": "#4ade80",
      "failed": "#f87171",
      "broken": "#fb923c",
      "skipped": "#94a3b8",
      "unknown": "#64748b",
      "accent": "#818cf8",
      "background": "#0f1117",
      "surface": "#1a1d27",
      "surface2": "#22263a",
      "text": "#f1f5f9",
      "textMuted": "#94a3b8",
      "border": "#2a2d3a"
    }
  }
}
```

---

## Views

| View          | Description                                                  |
| ------------- | ------------------------------------------------------------ |
| Overview      | Pass rate, status counts, severity breakdown, timing         |
| Categories    | Failures grouped by error message with count badges          |
| Suites        | Test tree by parent/sub suite with sort and status filters   |
| Graphs        | Status donut, severity bar, duration histogram, trend charts |
| Timeline      | Gantt-style execution view across hosts and threads          |
| Behaviours    | Tests organised by epic → feature → story                    |
| Tags          | Tests grouped by tag                                         |
| History Trend | Pass rate and result trends across builds                    |

---

## Requirements

- Node.js 18 or higher
- Playwright configured with the Allure reporter (`allure-playwright`)