Comments (9)
instead of forcing to customize WebAssert (which also means we will never be able to add new kinds of failures in the proposed API as that would break BC for your callback), a cleaner solution would be to use the dedicated PHPUnit feature to handle some exceptions as failures.
See https://github.com/minkphp/driver-testsuite/blob/af6107c1f16f4c43c19ea162e0da88d55c6cf21a/tests/TestCase.php#L74-L81 where our driver testsuite uses that hook to mark tests as skipped instead of errored when a Behat\Mink\Exception\UnsupportedDriverActionException
exception is thrown. You could do the same to turn Behat\Mink\Exception\ExpectationException
into a failure instead
from mink.
Yes but doing that means re-throwing the exception from the onNotSuccessful and therefore changing the exception type. We have tried to propose changes to PHPUnit to facilitate this see sebastianbergmann/phpunit#4983 (comment)
Atm if we want to mark Mink exceptions as PHPUnit failures we have do something like:
if ($t instanceof MinkException) {
$e = new AssertionFailedError($t->getMessage(), $t->getCode(), $t);
$trace = $t->getTrace();
foreach ($trace as $i => $call) {
unset($trace[$i]['args']);
}
$reflection = new \ReflectionProperty($e, 'serializableTrace');
$reflection->setValue($e, $trace);
throw $e;
}
in order to preserve the trace. Which in my mind not very sensible.
from mink.
AFAIU, the need for this complex code is caused by AssertionFailedError loosing the chained exception when serializing it for process isolation. I would rather work on fixing that in PHPUnit (as chaining exceptions was the suggested solution in sebastianbergmann/phpunit#4983 (comment))
from mink.
I have filed sebastianbergmann/phpunit#5068 which, I think, would solve the trace issue while using the solution proposed here in #835 (comment) which seems to me the cleanest one.
from mink.
PHPUnit rejected sebastianbergmann/phpunit#5069 and will not pursue sebastianbergmann/phpunit#5068.
from mink.
Well, if he decided that mapping the details is the way to go, he should probably bundle an utility in PHPUnit to make it easy to copy the trace, given the hacks it requires. but that should be discussed with PHPUnit, as that's clearly a PHPUnit limitation here.
The proposal done here adds lots of complexity in Mink and means that we cannot add new assertions outside of major versions as it would change the requirements for that callback.
from mink.
Alright, I understand the position here. I will try something else on Drupal side, before calling time of death. Thanks
from mink.
sebastianbergmann/phpunit#5201 might allow to solve the root cause without the need for this weird feature request. So you can subscribe to that issue.
from mink.
Thanks for the pointer, subscribed there.
I’d say what’s weird here could be the solution - the feature request per se is quite sensible.
from mink.
Related Issues (20)
- Feature: set basic auth after session start and reset HOT 3
- PHP 8.1 compatible release HOT 10
- Element attribute not exists HOT 1
- symfony/css-selector 6.0 compatibility with behat/mink HOT 1
- Symfony 6 compatible release
- Mink's use of stripos leads to some empty string behaviors in PHP 8 HOT 3
- Element not interactable even though it is in view (scrolled to) and visible HOT 1
- Add case-sensitive comparison option to function WebAssert::elementContains HOT 5
- Empty read; connection dead HOT 1
- Support Browserless HOT 2
- GET Request HOT 2
- Is this project active? HOT 2
- Strictly typed methods HOT 3
- Class "Behat\Mink\Mink" not found HOT 5
- Release with Symfony 7
- responseHeaderEquals() can no longer be used to check for existence HOT 3
- submit form and get resulting page?! HOT 1
- Unable to switch to frame on Selenium 3.x HOT 7
- Switching windows by name or handle? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mink.