Skip to main content

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.

Versions at a glance
  • 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 and curl.sh per 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): adds curlOnFailedTest, and an explicit apiLog.colors now 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 uninstall playwright-colorful-logger
npm install --save-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.

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.

tests/example.spec.ts
-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​

These change your output

The first rows change what you see in logs. Review them before merging the migration.

Areaplaywright-colorful-loggerplaywright-logger-proRevert with
ColoursOn 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 secretsLogged 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 listsA 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 requestsLogged 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 requestsTimeouts 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, bodiesmaxBodyLength 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, contextContext headers and cookies were not included.extraHTTPHeaders and (redacted) cookie-jar cookies are included.None
Request lineWithout 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 optionsUndefined behaviour.A one-time [playwright-logger-pro] warning and the default.None
Binary and control charactersBinary 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 (default false, 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: false keeps the output plain, and with colors unset nothing changes. If you set colors: true project-wide to colour the verbose lines, the compact output is now coloured in CI logs too (with the reporter registered); use colors: !process.env.CI to keep CI plain.

From 0.3 to 0.4​

The default output changed

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' }.

playwright.config.ts
// 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:

ListAdded in 0.4.0
Headersproxy-authorization, x-auth-token
Query parametersrefresh_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.30.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'falsefalse, unchanged
Valuestrue, false, 'on-failure'Also '5xx', '4xx+', 'always', 'never'. In compact output true is 'always', false is 'never' and 'on-failure' is '4xx+'.
'always'n/aEvery 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'.

ChangeNotes
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 optionsformat, slowThresholdMs, timeColumn, details, bodyPreviewChars, theme, ascii, mask. See Configuration.
New entry pointplaywright-logger-pro/reporter.
JSON attachmentTests with API calls get a playwright-logger-pro.json attachment (masked records), which the reporter reads.
ColourCompact 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:

Browser logging is on by default

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.

ChangeNotes
New browserLog option, browserLogger fixture, attachBrowserLogger()See Browser logging.
LoggerOptions type and mergeTests export from /fixturesUse defineConfig<LoggerOptions>().
Step locations stay in your spec fileWrapper 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.48The title of a logged request is apiRequestContext.get(...) again (it was apiRequestContext.apply(...)).
exports mapPer-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 exportsattachBrowserLogger, 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).