Registry / testing / playwright-mongodb-reporter

playwright-mongodb-reporter

JSON →
library0.1.7jsnpmunverified

A MongoDB reporter for Playwright test results that saves suite and test outcomes directly to a MongoDB database. Current stable version is 0.1.7. The package is maintained and follows Playwright's release cadence. It supports both connection string and credential-based MongoDB authentication, and uniquely allows splitting test and suite titles into common and unique parts using a '-|-' separator for better organization. Ships TypeScript types. Requires @playwright/test ^1.49.1 and Node >=18.

npm install playwright-mongodb-reporter
INSTALL
IMPORT
SIG · PLAYWRIGHT-MONGODB
P
playwright-mongodb-reporter
testingjavascriptv0.1.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MongoReporter
import MongoReporter from 'playwright-mongodb-reporter'
import { MongoReporter } from 'playwright-mongodb-reporter'
The package exports a default class. Named import will fail.
reporter configuration
reporter: [['playwright-mongodb-reporter', { mongoUri: '...', dbName: '...', collectionName: '...' }]]
reporter: ['playwright-mongodb-reporter']
Options object is required. Without options, the reporter will fail to connect.
require
const MongoReporter = require('playwright-mongodb-reporter').default
const MongoReporter = require('playwright-mongodb-reporter')
In CommonJS, .default is needed because the package uses ESM-style default export.

Playwright config using playwright-mongodb-reporter with MongoDB connection string and database options.

import { defineConfig } from '@playwright/test'; import MongoReporter from 'playwright-mongodb-reporter'; export default defineConfig({ reporter: [ ['playwright-mongodb-reporter', { mongoUri: process.env.MONGO_URI ?? 'mongodb://localhost:27017', dbName: 'playwright_reports', collectionName: 'test_results' }] ], projects: [ { name: 'Desktop Chromium', use: { browserName: 'chromium' } } ] });
Debug
Known issues
breakingRequires @playwright/test version ^1.49.1 (peer dependency) and Node >=18.0.0.
fix
Update @playwright/test to ^1.49.1 or later, and ensure Node >=18.
affects: <0.1.0
breakingIf mongoUri is not provided, you must provide credentials object. Using both may cause ambiguity.
fix
Provide either mongoUri or credentials, not both.
affects: >=0.1.0
deprecatedUsing 'credentials' object is deprecated in favor of 'mongoUri'.
fix
Replace credentials with mongoUri connection string.
affects: >=0.1.0
gotchaTest and suite titles containing '-|-' are split into main and subtitle. This may cause unexpected data structure if your titles contain '-|-' by accident.
fix
Avoid using '-|-' in your test titles unless you intend to use the split feature.
affects: >=0.1.0
gotchaThe reporter only exports a default export, not a named one. TypeScript users importing named export will get undefined.
fix
Use default import: import MongoReporter from 'playwright-mongodb-reporter'
affects: >=0.1.0
gotchaThe reporter writes to MongoDB after each test, not at the end of the full run. If the process crashes, partial results may be saved.
fix
Design tests to be idempotent or use a cleanup mechanism for partial runs.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: MongoReporter is not a constructor
Using named import instead of default import.
fix
Change import to: import MongoReporter from 'playwright-mongodb-reporter'
Error: MongoClient is not defined
Missing or invalid mongoUri or credentials in options.
fix
Ensure you provide either mongoUri (string) or credentials object in the reporter options.
Error: Cannot find module 'playwright-mongodb-reporter'
Package not installed or peer dependency missing.
fix
Run: npm install playwright-mongodb-reporter @playwright/test@^1.49.1
TypeError: Cannot read properties of undefined (reading 'mongoUri')
Options object is provided but empty or missing required fields.
fix
Make sure to pass an options object with at least mongoUri or credentials.
Upgrade
Version history
0.1.7latest on npm
Audit
Dependencies
@playwright/testrequiredPeer dependency - required to use Playwright's reporter interface
Agent activity
2 hits · last 30 days
node
2
Resources
playwright-mongodb-reporter — npm install playwright-mongodb-reporter · libregistry