stefanhaerter's avatar

Laravel Artisan Test Command

Hi everyone,

I use Laravel 8 in a project with Tests. I wrote a custom artisan command which runs the test command and mails its output to a mail address. Unfortunately, in the output there are ANSI sequences. If I try to run the command "php artisan test --no-ansi", I get the response "Unknown option "--no-ansi"". Has anyone a tip?

Kind regards Stefan

0 likes
6 replies
neilstee's avatar

@stefanhaerter don't forget to mark it as "Best Answer" if it solves your problem so others find it useful as well 😉

1 like
stefanhaerter's avatar

Sorry to bother you with another issue... I have the following code

Artisan::call('test', ['colors' => 'off']);

And it seems to ignore the option. Even tried

Artisan::call('test --colors=off');

and

Artisan::call('test', ['--colors' => 'off']);<

neilstee's avatar

@stefanhaerter hmm that's weird.

I'm not sure if this is a good idea but instead of running Artisan::call() why not exec() or shell_exec()?

For example:

$output = shell_exec('php artisan test --colors=off');
1 like
stefanhaerter's avatar

It did the job on my local machine, will test it on the server. Thank you for your time and patience =)

1 like

Please or to participate in this conversation.