Recently started working on some JavaScript tests by extending JavascriptTestBase in drupal 8.2 and the biggest problem currently is debugging.

Phantomjs is installed and i have no problem running JavaScript tests. Xdebug is installed too.


is not returning any output, maybe some additional configuration is needed?

file_put_contents('/Users/me/debug.html', $this->getSession()->getDriver()->getHtml('/html/body'))

is giving me a half broken page.

I would really appreciate if someone can share how they debug these tests and how they set it up, some useful links. The biggest help would be to be able to take screenshots but any info on this topic is welcome.

  • getScreenshot is a Mink framework method and the API documentation is available either in Mink or on api.drupal.org. The return value is a string screenshot of MIME type image/* depending on driver (e.g., image/png, image/jpeg).
    – mradcliffe
    Jul 19 '16 at 13:06
  • thanks. thought that this should work, looks like it might be a permission problem, on another machine both commands are working fine.
    – Denchev
    Jul 20 '16 at 3:11

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() {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.