Migration from playwright-colorful-logger
playwright-colorful-logger was renamed to playwright-logger-pro. Every version of the old package is deprecated on npm with a pointer to the new name, and no new versions of it will be published. The apiLog option key and the types are unchanged, so migrating is mostly a rename.
playwright-colorful-logger@0.1.0: the original package. API logging only.playwright-logger-pro@0.1.0: the renamed package, API logging only, with the fixes described in Behaviour changes.playwright-logger-pro@0.2.0: adds browser logging. See From 0.1 to 0.2.playwright-logger-pro@0.3.0: adds coloured curl output andcurl.shper test.playwright-logger-pro@0.3.1: metadata and docs only (keywords, description, npm links). No changes needed.playwright-logger-pro@0.4.0: compact output and a reporter, new defaults. See From 0.3 to 0.4.playwright-logger-pro@0.4.1: a fix to the repository's own tests, the README and the upgrade notes. No behaviour changes.playwright-logger-pro@0.4.2(this documentation): addscurlOnFailedTest, and an explicitapiLog.colorsnow also colours the reporter. See From 0.4.1 to 0.4.2.
Why the rename
The package now logs more than API requests: it records what a test does in the browser as well. The new name says what it is, and the old name stays deprecated so existing installs keep working and tell you where to go.
Steps
1. Swap the dependency
- npm
- pnpm
- Yarn
npm uninstall playwright-colorful-logger
npm install --save-dev playwright-logger-pro
pnpm remove playwright-colorful-logger
pnpm add --save-dev playwright-logger-pro
yarn remove playwright-colorful-logger
yarn add --dev playwright-logger-pro
@playwright/test 1.30 or newer and Node.js 18 or newer are required, as before for Playwright, and new for Node.
2. Replace the package name in your imports
The subpaths are the same (/fixtures), so only the package name changes.
- macOS / Linux
- Windows (PowerShell)
grep -rl "playwright-colorful-logger" --include='*.ts' --include='*.js' --include='*.mjs' --include='*.cjs' --include='*.json' . \
--exclude-dir=node_modules | xargs sed -i.bak 's/playwright-colorful-logger/playwright-logger-pro/g'
# review with git diff, then remove the backups:
find . -name '*.bak' -not -path './node_modules/*' -delete
On macOS, sed -i.bak works as written. On GNU/Linux it does too.
Get-ChildItem -Recurse -Include *.ts,*.js,*.mjs,*.cjs,*.json -File |
Where-Object { $_.FullName -notmatch '\\node_modules\\' } |
ForEach-Object {
(Get-Content $_.FullName -Raw) -replace 'playwright-colorful-logger', 'playwright-logger-pro' |
Set-Content -NoNewline $_.FullName
}
-import { test, expect } from 'playwright-colorful-logger/fixtures';
+import { test, expect } from 'playwright-logger-pro/fixtures';
3. Clean up the lockfile
Your package manager rewrote the lockfile when you installed the new package. Check that playwright-colorful-logger is gone from package.json and from the lockfile (npm ls playwright-colorful-logger should report nothing).
4. Review the behaviour changes
Read the next two sections. Most are improvements, and each can be reverted with one option.
Behaviour changes from playwright-colorful-logger
The first rows change what you see in logs. Review them before merging the migration.
| Area | playwright-colorful-logger | playwright-logger-pro | Revert with |
|---|---|---|---|
| Colours | On only when stdout is a TTY. Colourless under the test runner. | On by default under playwright test (it sets FORCE_COLOR for workers). NO_COLOR turns them off. On Playwright 1.64 with piped output the reporter strips colour from stdout, while the sink files keep it (see Troubleshooting). | colors: false |
| Query-string secrets | Logged as is. | Values of api_key, apikey, token, access_token, password and secret are masked in logged URLs and curl. | replaceDefaultRedaction: true with your own redactQueryParams (not recommended) |
| Header redaction lists | A custom redactHeaders replaced the defaults. | Custom lists are merged with the defaults, so authorization, cookie, set-cookie and x-api-key stay masked. | replaceDefaultRedaction: true |
| Redirected requests | Logged and curl'd the final URL and method. | Log and curl the originally requested URL and method. The curl adds -L, or one curl per step when the method changes. | None |
| Failing requests | Timeouts and connection errors were not logged. | A ✖ … failed line is logged (and a curl for curl: true / 'on-failure'), then the error is rethrown. | None |
| curl, bodies | maxBodyLength did not apply; multipart, GET with a body and HEAD did not replay; binary bodies sent the text <binary body omitted>. | maxBodyLength applies to the curl body (marked with a # request body truncated note); multipart (--form-string, -F), -X GET, --head and --data-binary '@request-body.bin' replay correctly. | None |
| curl, context | Context headers and cookies were not included. | extraHTTPHeaders and (redacted) cookie-jar cookies are included. | None |
| Request line | Without params. | Includes params in the URL. | None |
undefined options | { curl: undefined } overwrote the default with undefined. | An option set to undefined uses its default. | None |
| Invalid options | Undefined behaviour. | A one-time [playwright-logger-pro] warning and the default. | None |
| Binary and control characters | Binary responses were decoded as text; escape sequences in bodies reached the terminal. | Binary responses are summarised as <binary N bytes (type)>; control characters are escaped. | None |
From 0.4.1 to 0.4.2
Nothing needs to change. Two things differ:
- New option
curlOnFailedTest(defaultfalse, so no change unless you set it):'last'records the curl of the last call made before a test failed, whatever its status, and'all'of every call. See Compact output. - An explicit
apiLog: { colors: true }now colours the compact output, the reporter's included, even when it is piped. Before, the reporter detected a terminal by itself and ignored it.colors: falsekeeps the output plain, and withcolorsunset nothing changes. If you setcolors: trueproject-wide to colour the verbose lines, the compact output is now coloured in CI logs too (with the reporter registered); usecolors: !process.env.CIto keep CI plain.
From 0.3 to 0.4
Compact is now the default. API calls print one line each (format: 'compact') instead of the line-by-line 0.3 output, and the detail (response body, curl) appears only under failed calls of a failed test. To restore the 0.3 output exactly, set apiLog: { format: 'verbose' }.
// The new output: register the reporter after `list`.
reporter: [['list'], ['playwright-logger-pro/reporter']],
// Or keep the 0.3 output (headers, bodies, response, curl, the #!/bin/sh curl.sh):
use: { apiLog: { format: 'verbose' } },
Without the reporter the fixture prints the lines itself, above the result line and without the total.
What else changed
More values are masked by default. Your own lists are still merged with the defaults, and replaceDefaultRedaction: true still drops them. All lists are matched case-insensitively and exactly, and they also apply to format: 'verbose'. What 0.4.0 adds to the 0.3 lists:
| List | Added in 0.4.0 |
|---|---|
| Headers | proxy-authorization, x-auth-token |
| Query parameters | refresh_token, key, signature, sig |
| JSON and form body keys (the default list was empty) | password, token, accessToken, refreshToken, secret, apiKey, cardToken, cardNumber, cvv, pin, access_token, refresh_token, api_key, card_number |
If a test asserts on a response field called token, password, secret, pin and so on, the logged copy now shows *** for it. Only the log changes, never the real request or response.
curl has a default and new values.
| 0.3 | 0.4 | |
|---|---|---|
| Default (compact) | false: no curl | '5xx': calls with status >= 500, and network errors, get a curl. It is printed in the │ block under the call when its test failed, and written to a curl*.sh script attached to the report. A 4xx gets its ← 404 … block with no curl. |
Default with format: 'verbose' | false | false, unchanged |
| Values | true, false, 'on-failure' | Also '5xx', '4xx+', 'always', 'never'. In compact output true is 'always', false is 'never' and 'on-failure' is '4xx+'. |
'always' | n/a | Every call gets a curl in the playwright-logger-pro.json attachment. The curl*.sh scripts are attached only when the test failed or with details: 'always'. The console still prints a curl only under failed calls (status >= 400 or a network error). |
To get a curl for 4xx as well, set apiLog: { curl: '4xx+' }; to turn it off, curl: 'never'.
| Change | Notes |
|---|---|
curl.sh in compact | #!/usr/bin/env bash, set -euo pipefail, a ${VAR} placeholder for each masked value with a guard, and only for failed tests (or details: 'always'). format: 'verbose' keeps the 0.3 file. |
| New options | format, slowThresholdMs, timeColumn, details, bodyPreviewChars, theme, ascii, mask. See Configuration. |
| New entry point | playwright-logger-pro/reporter. |
| JSON attachment | Tests with API calls get a playwright-logger-pro.json attachment (masked records), which the reporter reads. |
| Colour | Compact output follows the rules of curlFormat.colors: 'auto' (none on CI, with NO_COLOR or when piped); FORCE_COLOR alone does not colour it. An explicit apiLog.colors (0.4.2) or reporter colors decides. |
From 0.1 to 0.2
If you are already on playwright-logger-pro@0.1.0, these are the changes in 0.2.0:
browserLog is enabled for everyone who imports test from playwright-logger-pro/fixtures, with quiet defaults: nothing is printed or attached while a test passes; on failure the timeline is printed once and attached to the report. Opt out per project or suite:
use: { browserLog: { enabled: false } }
When disabled, no page-level patch or listener is installed for that test.
| Change | Notes |
|---|---|
New browserLog option, browserLogger fixture, attachBrowserLogger() | See Browser logging. |
LoggerOptions type and mergeTests export from /fixtures | Use defineConfig<LoggerOptions>(). |
| Step locations stay in your spec file | Wrapper frames are hidden from Playwright's stack attribution, which also fixes request.* steps and errors that used to point into dist/. |
| Step titles on Playwright 1.30–1.48 | The title of a logged request is apiRequestContext.get(...) again (it was apiRequestContext.apply(...)). |
exports map | Per-condition types (.d.mts for import, .d.ts for require) and a ./package.json export. Builds target Node 16 syntax. |
redactHeaders() | Accepts an optional third argument, the mask (default ***). |
| New exports | attachBrowserLogger, resolveBrowserConfig, DEFAULT_BROWSER_CONFIG, DEFAULT_SENSITIVE_KEYS, DEFAULT_SENSITIVE_SELECTORS, renderBrowserEventText, renderBrowserEventJsonl, and the browser types. |
"I see a deprecation warning"
If npm install prints a deprecation notice for playwright-colorful-logger, that is expected: the package was renamed. Follow the steps above. The warning disappears once the old package is out of your dependency tree, including transitive dependencies in your lockfile (npm ls playwright-colorful-logger shows who still pulls it in).