Troubleshooting
No colours, or colours where you do not want them
With colors unset, the default follows the environment: off for NO_COLOR or FORCE_COLOR=0, on for any other FORCE_COLOR/DEBUG_COLORS or PLAYWRIGHT_FORCE_TTY, on for a TTY. playwright test sets FORCE_COLOR for its workers, so colours are normally on.
The printed curl is stricter: plain in CI, under NO_COLOR and TERM=dumb, and when the runner's output is piped. In a local terminal it is coloured with no setting (the runner tells its workers that its stdout is a terminal). If it is plain where you expect colours, check that CI and NO_COLOR are unset, that the output is not piped (| tee, an IDE panel) and that a spec file imports playwright-logger-pro; then force it with PLAYWRIGHT_FORCE_TTY=1 or curlFormat: { colors: true }. See When the curl is coloured.
colors: true only controls what the logger writes. On Playwright 1.64 (checked on 1.64.1), when the reporter's own output is piped (not a TTY), the reporter strips every ANSI code from the test stdout it forwards, so the console shows no colours even with colors: true. The sink files keep them: lines sent to a sink (a file, an attachment) arrive with the colours intact. Run in a terminal, or use a sink.
- No colours in the VS Code play button (or any panel that captures the output): the reporter detects a terminal, and there is none. Set
apiLog: { colors: !process.env.CI }, or on the reporter['playwright-logger-pro/reporter', { colors: !process.env.CI }]. See Compact output › Colours. - No colours in CI: your runner may not set
FORCE_COLORfor workers, orNO_COLORis set. Force them:apiLog: { colors: true }andbrowserLog: { colors: true }.colors: truewins overNO_COLOR. - Escape codes like
[32min a log viewer: the viewer does not render ANSI. SetNO_COLOR=1orcolors: false(Jenkins: enable the AnsiColor plugin instead). - Colours in a file: output sent through your own
sinkfollowscolors. Setcolors: falsefor files. Browser-log attachments and files are always plain.
No logs at all
- You imported
testfrom@playwright/test. Import fromplaywright-logger-pro/fixtures. A spec that uses the plaintestis not instrumented. apiLog: { enabled: false }orbrowserLog: { enabled: false }is set in config or intest.use().- You merged fixtures through a plain
test(mergeTestsfrom@playwright/testwith only your own tests). ImportmergeTestsfromplaywright-logger-pro/fixturesand merge ourtestin. - Browser log: nothing is printed for a passing test by design. Set
print: trueto see it live. API-only tests (no browser activity) produce no browser-log output. - You use
request.newContext()orplaywright.requestdirectly: those are not therequestfixture. Wrap them withwrapRequestContext(). - Pages created outside a fixture (
beforeAll, scripts) needattachBrowserLogger(page).
Duplicate lines
- Wrapping a context twice (
wrapRequestContexton therequestfixture of ourtest) logs each request twice. Use one or the other. - With
print: trueandincludeApiLog: true, apiLog lines are printed once (live), and copied into the attachment and file only.
TS2307 on the /fixtures import
Cannot find module 'playwright-logger-pro/fixtures':
- Make sure you are on a version with
typesVersions/exportstypes (0.1.0 or later ofplaywright-logger-pro). moduleResolutioncan benode/node10,node16/nodenextorbundler. If you useclassicor an older TypeScript, upgrade.- Delete
node_modules/.cacheor restart the TypeScript server after switching packages.
The curl does not replay
- Windows shells: curl output is for POSIX shells (bash, zsh, sh, Git Bash, WSL). In PowerShell, quoting differs and
\line continuation does not work. ***in the command: those values were redacted. Put the real value back. A compactcurl.shhas${VAR}placeholders instead:exportthe variables it names (it stops withexport TOKEN firstif one is missing), then runbash curl.sh.- Multipart files: file parts are read from disk (
-F 'name=@file'). Put the file next to where you run curl, as the comment in the curl says. - Binary body: save the bytes as
request-body.binfirst. - Cookies: cookies set by the response itself are not included; only those in the cookie jar before the request.
- Redirects: Playwright's redirect rules differ from
curl -L. A redirected non-GET request is replayed one curl per step, and whetherCookieand a cross-originAuthorizationare forwarded depends on your Playwright version (1.30 – 1.59 forwardAuthorization, 1.60+ drops it). See API logging. - Truncated: the command starts with
# request body truncated. RaisemaxBodyLength. - Not in the curl:
httpCredentials, proxy, client certificates,ignoreHTTPSErrors.
Step locations point into node_modules
The library hides its own frames from Playwright's stack attribution. If it cannot (an unusual Playwright layout), it falls back to scrubbing stacks and step locations may point into the library. Run with DEBUG=plp to print a warning when that fallback is used, and open an issue with your Playwright version.
There is no browser log for my beforeAll page
Pages created in beforeAll belong to no test. Call attachBrowserLogger(page); its events go to whichever test is running.
A secret shows up in the browser log
The target did not look sensitive. See Redaction & security: use getByLabel('Password')-style locators, redact.values, redact.selectors, inspectInputType or fillValues: 'always'.
If the value was transformed on its way to the log (base64, double-encoded, HTML-escaped, split over several console.log arguments, or a Set-Cookie value set by the server), the logger does not recognise it: list the value in redact.values or switch the echoing channel off. See the known limits.
Also check these cases:
- Turning off
browserConsoleandnetworkdoes not cover action lines (a base64 value passed topage.evaluate), page errors, dialog text or navigation URLs. Add the encoded form toredact.values, or useactions: false,pageErrors: falseornavigation: false(navigationcovers dialogs and navigation URLs). - A value that mixes escaped and literal forms, or mixes upper- and lower-case hex within one value (
%2fnext to%2F), is not matched. Lower and upper case are matched per value. - A card, expiry or PAN field is missed: see Sensitive field detection.
Huge logs and slow runs
- Reduce bodies:
maxBodyLength,logBody: false,logHeaders: false. - Reduce the browser log:
browserConsole: 'error',network: false,maxEvents,maxArgLength. location: truecosts one stack capture per action; leave it off for large suites.networkandredact.inspectInputTypeadd protocol traffic; they are off by default.
ESM/CJS loading errors
ERR_REQUIRE_ESMor "Cannot use import statement": use the right syntax for your project's"type". Bothrequire('playwright-logger-pro/fixtures')andimport ... from 'playwright-logger-pro/fixtures'are supported.- Importing from a path inside
dist/is not supported; use the two entry points.
pnpm strict peer dependencies
@playwright/test is a peer dependency. With pnpm, install it in the same package as playwright-logger-pro, and keep one copy of it in the workspace. See Installation.
A warning mentions an option
[playwright-logger-pro] option "x" must be …; using … means the option has an invalid type or value (or is unknown) and the default was used. Fix the option; nothing else is affected.