Pest: PhpStorm throws expression result is not used anywhere when using test() instead of it()

Created on 5 Dec 2020  ยท  6Comments  ยท  Source: pestphp/pest

Not sure if this is a pest issue, PhpStorm issue, or what but when I use test() instead of it() my entire test gets underlined

Screenshot 2020-12-05 at 10 47 57

When I use it() everything is fine.

Screenshot 2020-12-05 at 10 48 36

The test passes in both cases, either with it() or with test() used. The difference is only in the prepended it, which looks a bit odd in my case, which is why I opt for using the test() instead.

Screenshot 2020-12-05 at 10 50 00

Any idea why this would happen? When I hover over it() it correctly picks up the signature and docblock from vendor file, but not for test() function ๐Ÿคท๐Ÿผโ€โ™‚๏ธ . Bizzare thing is that it() is just a wrapper around the test() function.

I'm on macOS 11.0.1 (BigSur), using PHP 7.4.13, and on PhpStorm 2020.3. Also, I have the pest plugin installed.

Dependency versions

pestphp/pest                                   v0.3.15            An elegant PHP Testing Framework.
pestphp/pest-plugin                            v0.3.0             The Pest plugin manager
pestphp/pest-plugin-coverage                   v0.3.0             The Pest Coverage Plugin
pestphp/pest-plugin-init                       v0.3.1             The Pest Init plugin

phpunit/php-code-coverage                      9.2.5              Library that provides collection, processing, and rendering functionality for PHP code ...
phpunit/php-file-iterator                      3.0.5              FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                            3.1.1              Invoke callables with a timeout
phpunit/php-text-template                      2.0.4              Simple template engine.
phpunit/php-timer                              5.0.3              Utility class for timing
phpunit/phpunit                                9.5.0              The PHP Unit Testing framework.

EDIT

Ok, bizarre but if I use the test when testing exceptions, everything is fine.

Screenshot 2020-12-05 at 11 02 18

EDIT 2

Ok, when I pass the dataset to the test() function it doesn't report the error. But without it shows the "not used anywhere" warning.

bug

Most helpful comment

That would be great! ๐Ÿ‘ Then we can keep this repo's issues more clean.

So this is something we can fix in the plugin, just checked ๐Ÿ‘ However as a temporary fix until someone actually fixes it in the plugin you can do the following.
expression_disable

All 6 comments

cc @olivernybroe

@dingo-d Just for future reference, this should have been posted on https://github.com/pestphp/pest-intellij/ instead, as it is related to our phpstorm integration.

What you are experiencing is an inspection in phpstorm telling you that the result is not used, so your code is doing nothing, which is not true.

If you press the 3 dots you should be able to edit the inspection, hence getting the name of it. If you could give me this, then we should be able to add in a condition to disable the inspection when in a pest test.

Sorry, wasn't aware it was related to a different project.

The inspection gives me this

Expression result is not used anywhere 
Inspection info: Reports expressions that are calculated, but the calculation result is not used anywhere.
Such errors can be caused, for example, by misspelling the = operator as ==.

If you want, I can close this issue and open it in the pest-intellij project.

That would be great! ๐Ÿ‘ Then we can keep this repo's issues more clean.

So this is something we can fix in the plugin, just checked ๐Ÿ‘ However as a temporary fix until someone actually fixes it in the plugin you can do the following.
expression_disable

Was just going to say we could transfer the issue, but that's ok. ๐Ÿ‘๐Ÿป

@owenvoke Oh yeah, totally forgot that we can do that ๐Ÿ‘

Was this page helpful?
0 / 5 - 0 ratings

Related issues

khalyomede picture khalyomede  ยท  7Comments

AlexMartinFR picture AlexMartinFR  ยท  7Comments

olivernybroe picture olivernybroe  ยท  7Comments

reed-jones picture reed-jones  ยท  6Comments

nunomaduro picture nunomaduro  ยท  5Comments