gerardroche / sublime-phpunit

PHPUnit Sublime Text integration.
https://www.gerardroche.com
GNU General Public License v3.0
74 stars 11 forks source link

any plans for PestPHP? #103

Closed wingsline closed 1 year ago

wingsline commented 1 year ago

It would be a really welcome addition to detect PestPHP and run those tests also. Ty

gerardroche commented 1 year ago

You can change the phpunit executable to point to the pest executable:

    "phpunit.executable": "vendor/bin/pest",

This will run pest bin script instead of phpunit. The problem is that pest prints color codes:

Screenshot from 2023-04-08 12-46-11

PHPUnit automatically disables colors via the the --colors options which defaults to auto. You can manually disable colors in pest with --colors=never:

    "phpunit.options":
    {
        "colors=never": true
    },

But pest still prints color codes so the output now looks like this, a bit better but still an issue:

Screenshot from 2023-04-08 12-49-20

Colors in the Sublime Text output

Sublime Text output panels can't handle terminal color codes. PHPUnitKit handles the output by printing output with no color and then applying a syntax on which your color scheme is applied. I can add a syntax for Pest and add an easy to use boolean option phpunit.pest to enable pest. This would just the same as setting "phpunit.executable": "vendor/bin/pest" but I think the color code issue needs to be fixed in Pest. I think Pest should not print those when --colors=never is set.

gerardroche commented 1 year ago

I opened issue on the Pest issue for the --colors=never issue: https://github.com/pestphp/pest/issues/778

gerardroche commented 1 year ago

I've added some color output for Pest. To enable Pest you can replace the phpunit.executable:

        "phpunit.executable": "vendor/bin/pest",
    "phpunit.options":
    {
        "colors=never": true
    },

Until the color issue in Pest is fixed you will need to pass the --colors=never option to stop some of the color codes being printed. Pest still also has the issue of printing some color codes when it shouldn't, but I'm sure they'll fix those issues.

I'm thinking of added a phpunit.pest boolean option so that you would only need to enable it and under hood the plugin will configure the above settings.

You can also set these settings at a project level rather than global:

You can set settings on per-project basis: Menu > Project > Edit Project

{
   "settings": {
       "phpunit.executable": "vendor/bin/pest",
       "phpunit.options":
       {
           "colors=never": true,
       },
   }
}
gerardroche commented 1 year ago

I added the boolean setting phpunit.pest. Just set it to true to enable the Pest test runner.

gerardroche commented 1 year ago

Please open issues about missing syntax highlighting of the output