When I run
vendor/bin/pest --colors=never
Pest continues printing ascii chars that produces the following text:
[37;41;1m FAIL [39;49;22m[39m PestExample\Test\PhpUnitSourceFileTest[39m
[31;1m•[39;22m[39m [2mit can add two integers[22m[39m
[2m---[22m
[31;1m• PestExample\Test\PhpUnitSourceFileTest [39;22m> [31;1mit can add two integers[39;22m
[41;1m Error [49;22m
[39;1m Call to protected method PestExample\SourceFile::add() from context 'PestExample\Test\PhpUnitSourceFileTest'[39;22m
at [32mtests/PhpUnitSourceFileTest.php[39m:[32m18[39m
14â–• public function test_it_can_add_two_integers(): void
15â–• {
16â–• $source = new SourceFile();
17â–•
➜ 18▕ $result = $source->add(3, 2);
19â–•
20â–• $this->assertGreaterThan(0, $result);
21â–• }
22â–• }
[37;1mTests: [39;22m[31;1m1 failed[39;22m
[37;1mTime: [39;22m[39m0.03s[39m
For example, when I use --colors=never with PHPUnit, it correctly disables and prints just raw text:
PHPUnit 9.1.5 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 00:00.046, Memory: 6.00 MB
Related to #4 (In Infection PHP, we need a "raw" output without all those colours for terminal to parse the text);
Even without Infection, it's still the issue as some CI do not support such output as well
@maks-rafalko Maybe is better just change the printer to the default phpunit printer. what do you think?
--colors=never with default PHPUnit printer?colors=never should be supported by Pest. Why? For example, if Pest is used for Jenkins, there is no support for ascii codes (from what I see in my daily job :) ). So I see [37;41;1m FAIL insteaf of pretty raw FAILTo launch Pest with default phpunit printer, I usually do :
vendor/bin/pest --printer \\PHPUnit\\TextUI\\DefaultResultPrinter
Just try with --colors=never, work as expected :wink:
Anyway, to support in in pest, this could be done:
// src/Actions/AddsDefaults.php
if (!array_key_exists('printer', $arguments)) {
- $arguments['printer'] = new Printer();
+ $arguments['printer'] = new Printer(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? 'always');
}
Thank you!
Hi, I'm facing a problem when using pest on Windows.
When I run pest --colors=never, the output is not quite right.
pest

pest --colors=never

Just to make it clear, if I run from a terminal that supports colors, it will print the colors correctly, the issue here is the fact that --colors=never still sends colors information.
@crossworth, I think this is actually an issue with Collision rather than Pest.
Most helpful comment
To launch Pest with default phpunit printer, I usually do :
Just try with
--colors=never, work as expected :wink:Anyway, to support in in pest, this could be done: