Debugging JavaScript tests
I think that you are looking for JavascriptTestBase::createScreenshot() https://api.drupal.org/api/drupal/core!tests!Drupal!FunctionalJavascriptTests!JavascriptTestBase.php/function/JavascriptTestBase%3A%3AcreateScreenshot/8.2.x

See the following snippet from a core test:

  /**
   * Tests creating screenshots.
   */
  public function testCreateScreenshot() {
    $this-&gt;drupalGet('&lt;front&gt;');
    $this-&gt;createScreenshot('public://screenshot.jpg');
    $this-&gt;assertFileExists('public://screenshot.jpg');
  }