{"_id":"@amol.dev/pw-mongo-reporter","_rev":"2-35f27b64ee4080c316a5425ab8a314dd","name":"@amol.dev/pw-mongo-reporter","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@amol.dev/pw-mongo-reporter","version":"1.0.0","keywords":["playwright","playwright-reporter","reporter","mongodb","test-results"],"license":"MIT","_id":"@amol.dev/pw-mongo-reporter@1.0.0","maintainers":[{"name":"amol.dev","email":"amol.dev101010@gmail.com"}],"dist":{"shasum":"ee6b953d6daf4f090bccf25ba7b0620fa036e9df","tarball":"https://registry.npmjs.org/@amol.dev/pw-mongo-reporter/-/pw-mongo-reporter-1.0.0.tgz","fileCount":14,"integrity":"sha512-kfS2QGZkU5sa0Ekhn5oMtatfZgOq0zsZ2E2RIAGMnc4peNq5iGfIy2JrbJzy1GjhTX/XCy6CiQu7J0wzafi+Yg==","signatures":[{"sig":"MEUCIA9Koje55+QNbpvAxWS3MR7OGafILPGrycu7nJI6A+mcAiEAt46DF1yXtgrQyscn3NSHQ9DQBALRZy1Ni1MWA1Xdkjg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51716},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18"},"gitHead":"d7c7c8602d6cf0a8a7d8bb8eb634fdfa77a0f05a","scripts":{"build":"tsc -p tsconfig.json","clean":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"","prepare":"npm run build","typecheck":"tsc -p tsconfig.json --noEmit","prepublishOnly":"npm run clean && npm run build"},"_npmUser":{"name":"amol.dev","email":"amol.dev101010@gmail.com"},"_npmVersion":"11.7.0","description":"Playwright reporter that stores rich, queryable test results in MongoDB.","directories":{},"_nodeVersion":"22.18.0","dependencies":{"mongodb":"^6.5.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.4.0","@types/node":"^20.11.24","@playwright/test":"^1.44.0"},"peerDependencies":{"@playwright/test":">=1.30.0"},"_npmOperationalInternal":{"tmp":"tmp/pw-mongo-reporter_1.0.0_1787848372709_0.6946938440582984","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@amol.dev/pw-mongo-reporter","version":"1.0.1","description":"Playwright reporter that stores rich, queryable test results in MongoDB.","keywords":["playwright","playwright-reporter","reporter","mongodb","test-results"],"license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p tsconfig.json","clean":"node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"","prepare":"npm run build","prepublishOnly":"npm run clean && npm run build","typecheck":"tsc -p tsconfig.json --noEmit"},"engines":{"node":">=18"},"peerDependencies":{"@playwright/test":">=1.30.0"},"dependencies":{"mongodb":"^6.5.0"},"devDependencies":{"@playwright/test":"^1.44.0","@types/node":"^20.11.24","typescript":"^5.4.0"},"gitHead":"375c5071f3ee2170b1b019586337b56e8fbccf43","_id":"@amol.dev/pw-mongo-reporter@1.0.1","_nodeVersion":"22.18.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-cLmFHaZDiGEFMYZJqzsowWaeeRpwkhdWtxejU0orntaWGpzBOAPImMLcT5+GhvR7Vcp2AFiQY2KEWsb38MsPlg==","shasum":"5ea1a42b28856967bb83ba55b40080d2bcca74c2","tarball":"https://registry.npmjs.org/@amol.dev/pw-mongo-reporter/-/pw-mongo-reporter-1.0.1.tgz","fileCount":14,"unpackedSize":58496,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBdJ4wno6jte8qfpJioqYGkhNPdLdN6QhpXzGo8FyfOlAiEAj6OW3nlDcGgWkF46iPrIyMxDbXLWHj+KRWD84rapd0w="}]},"_npmUser":{"name":"amol.dev","email":"amol.dev101010@gmail.com"},"directories":{},"maintainers":[{"name":"amol.dev","email":"amol.dev101010@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pw-mongo-reporter_1.0.1_1787849997127_0.9895346286472015"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-27T16:32:52.393Z","modified":"2026-08-27T16:59:57.536Z","1.0.0":"2026-08-27T16:32:52.847Z","1.0.1":"2026-08-27T16:59:57.272Z"},"license":"MIT","keywords":["playwright","playwright-reporter","reporter","mongodb","test-results"],"description":"Playwright reporter that stores rich, queryable test results in MongoDB.","maintainers":[{"name":"amol.dev","email":"amol.dev101010@gmail.com"}],"readme":"# pw-mongo-reporter\n\nA [Playwright](https://playwright.dev) reporter that writes rich, queryable test\nresults into MongoDB — one document per test attempt. It is the data producer for\nthe [MongoDB Report Viewer](../../pw/monogReportViewer) dashboard (schema\nversion 2).\n\n## Install\n\n```bash\nnpm install --save-dev pw-mongo-reporter\n```\n\n`@playwright/test` is a peer dependency and must already be installed.\n\n## Usage\n\nAdd it to `playwright.config.ts`:\n\n```ts\nimport { defineConfig } from \"@playwright/test\";\n\nexport default defineConfig({\n  reporter: [\n    [\"list\"],\n    [\"pw-mongo-reporter\"],\n  ],\n});\n```\n\nWith no options and no `MONGO_URL`, the reporter is a no-op — tests run\nnormally and nothing is written.\n\n## Providing the MongoDB URL\n\nThere are two supported ways to give the reporter a connection string. Pick one.\n\n### Option A — pass it directly in the Playwright config\n\nUse this when the URL lives in your own config/secret loader, or you want\ndifferent databases per project.\n\n```ts\n// playwright.config.ts\nimport { defineConfig } from \"@playwright/test\";\n\nexport default defineConfig({\n  reporter: [\n    [\"list\"],\n    [\"pw-mongo-reporter\", {\n      mongoUrl: \"mongodb+srv://ci-writer:s3cr3t@cluster0.abcde.mongodb.net\",\n      dbName: \"playwright_tests\",\n      collectionName: \"test_results\",\n      enabled: true, // publish even outside CI; omit to keep it CI-only\n    }],\n  ],\n});\n```\n\nOptions always win over the matching environment variable. Avoid committing a\nreal credential — read it from wherever your app already keeps secrets, e.g.:\n\n```ts\n[\"pw-mongo-reporter\", { mongoUrl: myConfig.get(\"MONGO_URL\") }],\n```\n\n### Option B — pass it as a GitHub Actions secret (recommended for CI)\n\n1. **Add the secret:** GitHub repo → **Settings → Secrets and variables →\n   Actions → New repository secret** → name it `MONGO_URL`, paste the\n   connection string.\n\n2. **Expose it as an env var in the workflow step** that runs Playwright:\n\n   ```yaml\n   # .github/workflows/e2e.yml\n   name: E2E\n   on: [push, pull_request]\n\n   jobs:\n     test:\n       runs-on: ubuntu-latest\n       steps:\n         - uses: actions/checkout@v4\n         - uses: actions/setup-node@v4\n           with:\n             node-version: 20\n             cache: npm\n         - run: npm ci\n         - run: npx playwright install --with-deps\n\n         - name: Run Playwright tests\n           run: npx playwright test\n           env:\n             MONGO_URL: ${{ secrets.MONGO_URL }}\n             # optional overrides\n             MONGO_DB_NAME: playwright_tests\n             MONGO_COLLECTION: test_results\n             CYCLE_NAME: CI-${{ github.workflow }}-${{ github.run_number }}\n   ```\n\n3. **Consume it in the config** — either leave the reporter with no options (it\n   reads `MONGO_URL` from `process.env` itself):\n\n   ```ts\n   reporter: [[\"list\"], [\"pw-mongo-reporter\"]],\n   ```\n\n   or wire the env var through explicitly:\n\n   ```ts\n   reporter: [\n     [\"list\"],\n     [\"pw-mongo-reporter\", { mongoUrl: process.env.MONGO_URL }],\n   ],\n   ```\n\nBecause the reporter auto-detects CI (via `CI` / `GITHUB_RUN_ID` /\n`GITHUB_RUN_NUMBER`), it publishes on GitHub Actions with no `enabled` flag, and\nstays a no-op on developer machines where the secret is absent.\n\n## Configuration\n\n| Option               | Env var                 | Default            | Notes |\n| -------------------- | ----------------------- | ------------------ | ----- |\n| `mongoUrl`            | `MONGO_URL`             | —                  | Required to publish. If missing, the reporter is a no-op. |\n| `dbName`              | `MONGO_DB_NAME`         | `playwright_tests` | |\n| `collectionName`     | `MONGO_COLLECTION`      | `test_results`     | |\n| `cycleName`          | `CYCLE_NAME`            | auto-generated     | Groups a run's documents together. |\n| `enabled`            | —                       | auto (CI-only)     | When unset, publishing happens only in CI. Set `true`/`false` to force. |\n| `reportBaseUrl`      | `REPORT_BASE_URL`       | S3 site URL        | Base for public trace URLs, and the `{base}` slot of `htmlReportUrlTemplate`. |\n| `traceReportBaseUrl` | `TRACE_REPORT_BASE_URL` | —                 | Deprecated alias for `reportBaseUrl` (still honoured). |\n| `htmlReportUrl`      | `HTML_REPORT_URL`       | —                  | Explicit URL of this run's HTML report. Highest priority. |\n| `htmlReportUrlTemplate` | `HTML_REPORT_URL_TEMPLATE` | —            | Template expanded per run — see below. |\n\n### HTML report link\n\nThe [report viewer](../../pw/monogReportViewer) shows an \"HTML Report\" link on\nevery run. Give it a URL from here and it uses that verbatim; otherwise the\nviewer falls back to its own Settings-tab / build-time template.\n\n```ts\n// A) you already know the exact URL the CI job uploaded to\n[\"pw-mongo-reporter\", { htmlReportUrl: process.env.HTML_REPORT_URL }]\n\n// B) let the reporter build it per run\n[\"pw-mongo-reporter\", {\n  htmlReportUrlTemplate: \"{base}/{env}/{workflow}/{runNumber}/\",\n  reportBaseUrl: \"https://my-bucket.s3-website-us-west-1.amazonaws.com\",\n}]\n```\n\n```yaml\n# or entirely via env in the workflow\nenv:\n  HTML_REPORT_URL: https://my-bucket.s3.amazonaws.com/${{ github.workflow }}/${{ github.run_number }}/\n```\n\nTemplate placeholders: `{base}` `{env}` `{workflow}` `{runNumber}` `{runId}`\n`{branch}` `{commitSha}` `{cycleName}`. If any referenced placeholder has no\nvalue at runtime the URL is dropped (nothing is stored) rather than written\nhalf-formed.\n\n### CI detection\n\nBy default the reporter only publishes when it detects CI, via any of `CI`,\n`GITHUB_RUN_ID`, or `GITHUB_RUN_NUMBER`. Pass `{ enabled: true }` to publish from\na local run.\n\n### Run metadata\n\nThese GitHub Actions variables are captured automatically when present:\n`GITHUB_WORKFLOW`, `GITHUB_RUN_NUMBER`, `GITHUB_RUN_ID`, `GITHUB_REF_NAME` /\n`GITHUB_HEAD_REF`, `GITHUB_SHA`, `GITHUB_PR_NUMBER`.\n\n### Environment snapshot\n\n`ENV` and `BASE_URL` are always stored. These are stored when set: `ORG_ID`,\n`ORG_NAME`, `APP_ID`, `ORG_ID_PROFILE_APP`, `LOCALIZATION_INPUT_DATE_FORMAT`,\n`LOCALIZATION_TIME_FORMAT`.\n\n## Test annotations\n\nThe reporter reads a few annotation types off each test:\n\n```ts\n// Record an entity your test created (JSON string, one per annotation)\ntest.info().annotations.push({\n  type: \"entity-created\",\n  description: JSON.stringify({ entityType: \"booking\", entityId: \"bk_123\" }),\n});\n\n// Extra tags (also picked up from test.tags and @tags in the title)\ntest.info().annotations.push({ type: \"tag\", description: \"@regression\" });\n```\n\n## What gets stored\n\nOne document per test attempt, including: status, failure classification\n(`assertion` / `timeout` / `locator` / `navigation` / `auth` / `network` /\n`unknown`), normalized error message, top stack frame, structured assertion\ndetails, trace file path/URL, HTML report URL, tags, created entities, timing,\nretry number and run/environment metadata. See `TestDocument` in the type\ndefinitions for the full shape.\n\n## Failure modes\n\nThe reporter never fails a test run. A missing `MONGO_URL`, a connection error,\nor an insert error is logged and skipped; tests continue.\n\n## Development\n\n```bash\nnpm install\nnpm run build      # emits dist/ (CJS + .d.ts)\nnpm run typecheck\n```\n","readmeFilename":"README.md"}