qtreactjscapybaracapybara-webkitqt5.5

Capybara-Webkit: js/React is missing & Can't find variable: WeakMap


I am using Capybara-Webkit in my step-definitions for my cucumber feature files. This particular scenario tests that a successful login to a system. Capybara loads up the login form, enters the username and password perfectly, yet when it hits the login button it gets hung up on the loading page and never properly logs in.

The errors that are printed out to the console are:

  1. ReferenceError: Can't find variable: WeakMap

  2. Error: js/React is missing

  3. |TypeError: undefined is not an object (evaluating 'reagent.impl.util.memoize_1.call')
  4. TypeError: undefined is not an object (evaluating 'window["deps"]["fine"]')
  5. Feature :formatters cannot be installed. Unsupported Javascript context: Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) capybara-webkit Safari/538.1.
  6. Error: js/ReactDOM is missing
  7. (typeof goog == \"undefined\") console.warn(\"ClojureScript could not load :main, did you forget to specify :asset-path?\");goog.require(\"myapp.app\")

Relevant Info:

From what I gather from the forums (this one specifically: https://github.com/thoughtbot/capybara-webkit/issues/849) the lack of QtWebKit: 5.5.1 support for es6 might be the issue. I have tried installing an older version of qt (qt-everywhere-opensource-src-5.4.2) but I am getting build errors, and even if it did work its not a long term solution to use a much older version.

Any assistance on this issue would be appreciated. Thank you


Solution

  • capybara-webkit supports at most ES5. You are using ES6 features (WeakMap,etc). In order to test your app using capybara-webkit your app needs to be fully transpiled/polyfilled to ES5 compatibility using babel, etc. Reverting to an older Qt, would just make the support level in capybara-webkit worse, so that's not even a short term solution. If you don't want to transpile/polyfil another solution would be to change from using capybara-webkit to using selenium with headless chrome (although that has a few things that don't work currently too - resizing windows, multiple windows)