Drupal Test

Observation Mode

The idea here is that you can build a client demo using an end to end test. Then you may run the test in front of your client pausing as necessary to explain or discuss. You must define the "breakpoints" in your test code using ::waitForObserver. You have the ability to run the test either in demonstration mode or not. The following code illuminates this feature.

Enable Observation Mode

At the very least you must call ::beginObservation. How you implement this is up to you. At some point after that in the test class you should call ::waitForObserver one or more times.

Toggle observation mode with ENV

Adding a Demo "Breakpoint"

To pause the demo at the point just before a field has a value set on it, you would use something like the following:

    public function testSelectingMemberExposesMemberFields() {
      $el = $this->getDomElements([
       '.t-field_account_type',
      ]);

      // A button will be appended next to the element indicated by the argument
      // while in observation mode, otherwise this line of code does nothing.
      $this->waitForObserver('.t-field_account_type');

      $el['.t-field_account_type']->setValue('member');
    }

This is what is shown to the observer during the test run.

Observation Mode