-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
3.7.4, 3.8.1, 3.9
-
None
-
MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
-
MDL-67704-master
-
We currently do some weird things with pending js checks whereby we check too many times and can obscure failures.
Right now we actively check for pending JS in two places:
- behat_hooks::before_step_javascript
- behat_hooks::after_step_javascript
It's not possible to fail a step from an afterStep hook, so we also check for failures in another the I look for exceptions Step that we forcibly insert too.
Unfortunately we got a few things wrong and this is not happening.
What this means is that if a step is running slowly and fails the after_step_javascript hook, then it should capture that failure and display it immediately.
Unfortunately we are also resetting the currentstepexception in the BeforeStep hook.
As a result, it seems that what actually happens is:
- BeforeStep hooks are run
- Main step body runs
- We look for exceptions
- AfterStep hooks run including one that looks for pending JS
- [Repeat]
To take a more specific example:
- BeforeStep hooks are run
- Main step body runs
- We look for exceptions
- AfterStep hooks run including one that looks for pending JS
- pendingJS is found. The exception is stored in self::$currentstepexception
- Next step starts
- BeforeStep hooks are run
- before_step_javascript wipes the current self::$currentstepexception value
- before_step_exception looks for JS pending again
A couple of things can happen:
- The first pendingJS step fails, but the JS recovers in time for the second
- Both fail
- The first fails, but some more JS kicks off and causes the second to fail
This also means that we could be losing some of the exception checks.
We should move the pending JS check to be part of the Chained Step like we do for exceptions, and we should stop wiping the current exception holder in the before step hook too.