Skip to content

[Feature]: support stripANSIControlSequences in json reporter #33670

Open
@gofr

Description

@gofr

Version

1.48.2

Steps to reproduce

  1. Create simple test:
import { test, expect } from '@playwright/test';

test('color', () => {
expect('foo').toBe('bar');
})
  1. Run Playwright with colors turned off: FORCE_COLOR=0 DEBUG_COLORS=false npx playwright test

Expected behavior

I expect the output to lack any colors.

Actual behavior

Playwright's own output has no colors, but the output from expect does have colors. This part:

Error: expect(received).toBe(expected) // Object.is equality

Expected: "bar"
Received: "foo"

Additional context

This seems related to #32543.

#32764 changed DEBUG_COLORS to respect the environment, here (on line 40):

FORCE_COLOR: '1',
DEBUG_COLORS: process.env.DEBUG_COLORS === undefined ? '1' : process.env.DEBUG_COLORS,

If I make the same adjustment to FORCE_COLOR on line 39, the colors from expect disappear too.

Environment

System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
    Memory: 1.29 GB / 11.69 GB
    Container: Yes
  Languages:
    Bash: 5.1.16 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.48.2 => 1.48.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions