Installation
Requirements
| Supported | |
|---|---|
@playwright/test | 1.30 or newer (peer dependency) |
| Node.js | 18 or newer |
| Module systems | CommonJS and ES modules |
TypeScript moduleResolution | node (node10), node16/nodenext and bundler |
| Browsers | Chromium, Firefox and WebKit |
See Compatibility for what each Playwright version supports and what CI verifies.
Install
- npm
- pnpm
- Yarn
npm install --save-dev playwright-logger-pro
pnpm add --save-dev playwright-logger-pro
yarn add --dev playwright-logger-pro
@playwright/test is a peer dependency: the package never installs its own copy, so it always instruments the Playwright that runs your tests.
npm install playwright-logger-pro installs the latest version from npm. Browser logging (browserLog, browserLogger, attachBrowserLogger) needs 0.2.0 or later; 0.1.0 has API logging only. Pre-releases are published under the next tag.
Import
The package has two entry points.
- TypeScript
- JavaScript (ESM)
- JavaScript (CommonJS)
// The drop-in `test` / `expect`: both loggers are active.
import { test, expect } from 'playwright-logger-pro/fixtures';
// Building blocks, for when you do not use the fixtures.
import { wrapRequestContext, attachBrowserLogger } from 'playwright-logger-pro';
import { test, expect } from 'playwright-logger-pro/fixtures';
import { wrapRequestContext, attachBrowserLogger } from 'playwright-logger-pro';
const { test, expect } = require('playwright-logger-pro/fixtures');
const { wrapRequestContext, attachBrowserLogger } = require('playwright-logger-pro');
Type your config
apiLog and browserLog are Playwright option fixtures. Pass LoggerOptions to defineConfig so use is type-checked:
import { defineConfig } from '@playwright/test';
import type { LoggerOptions } from 'playwright-logger-pro/fixtures';
export default defineConfig<LoggerOptions>({
use: {
baseURL: 'http://localhost:3000',
apiLog: { curl: 'on-failure' },
browserLog: { network: 'failed' },
},
});
ApiLoggerOptions (only apiLog) and BrowserLoggerOptions (only browserLog) are exported as well.
TypeScript settings
Types resolve under every moduleResolution value. For node/node10, the package ships typesVersions so that playwright-logger-pro/fixtures resolves too. If your editor reports TS2307 on the /fixtures import, see Troubleshooting.
Monorepos and pnpm
With pnpm's strict node_modules, playwright-logger-pro finds @playwright/test through its peer dependency, so install both in the package that owns your Playwright config:
- npm
- pnpm
- Yarn
npm install --save-dev @playwright/test playwright-logger-pro
pnpm add --save-dev @playwright/test playwright-logger-pro
yarn add --dev @playwright/test playwright-logger-pro
Keep a single copy of @playwright/test per workspace: if the logger and your tests resolve different copies, the fixtures it extends are not the ones your tests run with.
Check the install
npm ls playwright-logger-pro @playwright/test
Then run any spec that imports from playwright-logger-pro/fixtures and a request should print → and ← lines. If nothing is printed, see No logs at all.
Uninstall
- npm
- pnpm
- Yarn
npm uninstall playwright-logger-pro
pnpm remove playwright-logger-pro
yarn remove playwright-logger-pro
Then switch your imports back to @playwright/test and remove apiLog and browserLog from use.