teampoltergeist / poltergeist

A PhantomJS driver for Capybara
MIT License
2.5k stars 415 forks source link

ReferenceError: Can't find variable: RWR #875

Closed jovergaag closed 7 years ago

jovergaag commented 7 years ago

I have recently installed rwr-redux in my project and the Rails feature specs now fail with the following error:

Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

       ReferenceError: Can't find variable: RWR
       ReferenceError: Can't find variable: RWR
           at http://127.0.0.1:65150/assets/application-a3b817ad22570913fde9f581c275f3c7cca4f7e364708af51a5226a506b3ef53.js:14564 in _mountNodes
           at :0 in dispatchEvent
           at http://127.0.0.1:65150/assets/application-a3b817ad22570913fde9f581c275f3c7cca4f7e364708af51a5226a506b3ef53.js:12191 in dispatch
           at http://127.0.0.1:65150/assets/application-a3b817ad22570913fde9f581c275f3c7cca4f7e364708af51a5226a506b3ef53.js:12191 in notifyApplicationAfterPageLoad
           at http://127.0.0.1:65150/assets/application-a3b817ad22570913fde9f581c275f3c7cca4f7e364708af51a5226a506b3ef53.js:12191 in pageLoaded
           at http://127.0.0.1:65150/assets/application-a3b817ad22570913fde9f581c275f3c7cca4f7e364708af51a5226a506b3ef53.js:12191

The pages definitely load without Javascript errors. If I use Selenium driver there is no longer an issue which makes me think this is something with Poltergeist. Any ideas what is going on here? Below are my package.json and Gemfile.lock.

Thank you

Gemfile.lock:

GIT
  remote: https://github.com/educationsuperhighway/ecto.git
  revision: 40624dbd1be6048df0fb76b0db09507c8546cc4d
  branch: master
  specs:
    ecto (8.7.0)
      dotenv-rails
      friendly_id (~> 5.1.0)
      kaminari (~> 0.17.0)
      material_girl
      paper_trail
      pg (~> 0.18)
      postgres-copy
      rails (~> 5.0)

GIT
  remote: https://github.com/educationsuperhighway/material_girl.git
  revision: 86591ad2445fe14d90198a1710828af94b6fd8b4
  branch: master
  specs:
    material_girl (2.1.1)
      kaminari (~> 0.16)
      pg (~> 0.18)
      rails (~> 5.0)
      sass-rails (~> 5.0)
      slim-rails (~> 3.0)
      therubyracer (~> 0.12)

GIT
  remote: https://github.com/netguru/react_webpack_rails.git
  revision: c02219040f99be37622ec753b38bf1750e527281
  branch: master
  specs:
    react_webpack_rails (0.6.0)
      rails (>= 3.2)

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.0.2)
      actionpack (= 5.0.2)
      nio4r (>= 1.2, < 3.0)
      websocket-driver (~> 0.6.1)
    actionmailer (5.0.2)
      actionpack (= 5.0.2)
      actionview (= 5.0.2)
      activejob (= 5.0.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.0.2)
      actionview (= 5.0.2)
      activesupport (= 5.0.2)
      rack (~> 2.0)
      rack-test (~> 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.0.2)
      activesupport (= 5.0.2)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.0.2)
      activesupport (= 5.0.2)
      globalid (>= 0.3.6)
    activemodel (5.0.2)
      activesupport (= 5.0.2)
    activerecord (5.0.2)
      activemodel (= 5.0.2)
      activesupport (= 5.0.2)
      arel (~> 7.0)
    activesupport (5.0.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (~> 0.7)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    addressable (2.5.0)
      public_suffix (~> 2.0, >= 2.0.2)
    arel (7.1.4)
    ast (2.3.0)
    autoprefixer-rails (6.3.7)
      execjs
    awesome_print (1.7.0)
    bcrypt (3.1.11)
    better_errors (2.1.1)
      coderay (>= 1.0.0)
      erubis (>= 2.6.6)
      rack (>= 0.9.0)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bootstrap-sass (3.3.6)
      autoprefixer-rails (>= 5.2.1)
      sass (>= 3.3.4)
    builder (3.2.3)
    byebug (9.0.5)
    capybara (2.13.0)
      addressable
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    cliver (0.3.2)
    coderay (1.1.1)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    coffeelint (1.14.0)
      coffee-script
      execjs
      json
    colorize (0.8.1)
    concurrent-ruby (1.0.5)
    crack (0.4.3)
      safe_yaml (~> 1.0.0)
    database_cleaner (1.5.3)
    debug_inspector (0.0.2)
    devise (4.2.0)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0, < 5.1)
      responders
      warden (~> 1.2.3)
    diff-lcs (1.2.5)
    dotenv (2.2.0)
    dotenv-rails (2.2.0)
      dotenv (= 2.2.0)
      railties (>= 3.2, < 5.1)
    erubis (2.7.0)
    execjs (2.7.0)
    factory_girl (4.7.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.7.0)
      factory_girl (~> 4.7.0)
      railties (>= 3.0.0)
    faker (1.6.6)
      i18n (~> 0.5)
    faraday (0.9.2)
      multipart-post (>= 1.2, < 3)
    faraday_middleware (0.10.1)
      faraday (>= 0.7.4, < 1.0)
    ffi (1.9.14)
    font-awesome-sass (4.6.2)
      sass (>= 3.2)
    foreman (0.82.0)
      thor (~> 0.19.1)
    formatador (0.2.5)
    friendly_id (5.1.0)
      activerecord (>= 4.0.0)
    globalid (0.3.7)
      activesupport (>= 4.1.0)
    growl (1.0.3)
    growlyflash (0.8.5)
      coffee-rails (>= 3.2.1)
      railties (>= 3.2, < 5.1)
    guard (2.14.0)
      formatador (>= 0.2.4)
      listen (>= 2.7, < 4.0)
      lumberjack (~> 1.0)
      nenv (~> 0.1)
      notiffany (~> 0.0)
      pry (>= 0.9.12)
      shellany (~> 0.0)
      thor (>= 0.18.1)
    guard-coffeelint (0.1.5)
      colorize (~> 0.7)
      guard (~> 2.0)
    guard-compat (1.2.1)
    guard-rspec (4.7.2)
      guard (~> 2.1)
      guard-compat (~> 1.1)
      rspec (>= 2.99.0, < 4.0)
    guard-rubocop (1.2.0)
      guard (~> 2.0)
      rubocop (~> 0.20)
    guard-zeus (2.0.1)
      guard (~> 2.0)
      guard-compat (~> 1.1)
      zeus (~> 0)
    hashdiff (0.3.1)
    hashie (3.4.4)
    heroku-deflater (0.6.2)
      rack (>= 1.4.5)
    honeybadger (2.7.1)
    i18n (0.8.1)
    jbuilder (2.5.0)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.1.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-turbolinks (2.1.0)
      railties (>= 3.1.0)
      turbolinks
    js-routes (1.3.0)
      railties (>= 3.2)
      sprockets-rails
    json (1.8.3)
    jwt (1.5.4)
    kaminari (0.17.0)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    launchy (2.4.3)
      addressable (~> 2.3)
    libv8 (3.16.14.19)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    lumberjack (1.0.10)
    mail (2.6.4)
      mime-types (>= 1.16, < 4)
    method_source (0.8.2)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mini_portile2 (2.1.0)
    minitest (5.10.1)
    multi_json (1.12.1)
    multi_xml (0.5.5)
    multipart-post (2.0.0)
    nenv (0.3.0)
    newrelic_rpm (3.16.0.318)
    nio4r (2.0.0)
    nokogiri (1.7.1)
      mini_portile2 (~> 2.1.0)
    notiffany (0.1.0)
      nenv (~> 0.1)
      shellany (~> 0.0)
    oauth2 (1.2.0)
      faraday (>= 0.8, < 0.10)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    omniauth (1.3.1)
      hashie (>= 1.2, < 4)
      rack (>= 1.0, < 3)
    omniauth-oauth2 (1.3.1)
      oauth2 (~> 1.0)
      omniauth (~> 1.2)
    omniauth-salesforce (1.0.5)
      omniauth (~> 1.0)
      omniauth-oauth2 (~> 1.0)
    orm_adapter (0.5.0)
    paper_trail (6.0.2)
      activerecord (>= 4.0, < 5.2)
      request_store (~> 1.1)
    paranoid2 (1.1.5)
      activerecord (>= 4.1.0)
    parser (2.3.1.2)
      ast (~> 2.2)
    pg (0.20.0)
    poltergeist (1.14.0)
      capybara (~> 2.1)
      cliver (~> 0.3.1)
      websocket-driver (>= 0.2.0)
    postgres-copy (1.1.2)
      activerecord (>= 4.0)
      pg (>= 0.17)
      responders
    powerpack (0.1.1)
    pry (0.10.4)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
    public_suffix (2.0.5)
    puma (3.4.0)
    rack (2.0.1)
    rack-cors (0.4.0)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (5.0.2)
      actioncable (= 5.0.2)
      actionmailer (= 5.0.2)
      actionpack (= 5.0.2)
      actionview (= 5.0.2)
      activejob (= 5.0.2)
      activemodel (= 5.0.2)
      activerecord (= 5.0.2)
      activesupport (= 5.0.2)
      bundler (>= 1.3.0, < 2.0)
      railties (= 5.0.2)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.2)
      activesupport (>= 4.2.0, < 6.0)
      nokogiri (~> 1.6)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    rails_12factor (0.0.3)
      rails_serve_static_assets
      rails_stdout_logging
    rails_serve_static_assets (0.0.5)
    rails_stdout_logging (0.0.5)
    railties (5.0.2)
      actionpack (= 5.0.2)
      activesupport (= 5.0.2)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rainbow (2.1.0)
    rake (12.0.0)
    rb-fsevent (0.9.7)
    rb-inotify (0.9.7)
      ffi (>= 0.5.0)
    rdoc (4.2.2)
      json (~> 1.4)
    ref (2.0.0)
    request_store (1.3.2)
    responders (2.3.0)
      railties (>= 4.2.0, < 5.1)
    restforce (2.4.2)
      faraday (~> 0.9.0)
      faraday_middleware (>= 0.8.8)
      hashie (>= 1.2.0, < 4.0)
      json (>= 1.7.5)
    rspec (3.5.0)
      rspec-core (~> 3.5.0)
      rspec-expectations (~> 3.5.0)
      rspec-mocks (~> 3.5.0)
    rspec-core (3.5.1)
      rspec-support (~> 3.5.0)
    rspec-expectations (3.5.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.5.0)
    rspec-its (1.2.0)
      rspec-core (>= 3.0.0)
      rspec-expectations (>= 3.0.0)
    rspec-mocks (3.5.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.5.0)
    rspec-rails (3.5.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 3.5.0)
      rspec-expectations (~> 3.5.0)
      rspec-mocks (~> 3.5.0)
      rspec-support (~> 3.5.0)
    rspec-support (3.5.0)
    rspec_junit_formatter (0.2.2)
      builder (< 4)
      rspec-core (>= 2, < 4, != 2.12.0)
    rubocop (0.41.2)
      parser (>= 2.3.1.1, < 3.0)
      powerpack (~> 0.1)
      rainbow (>= 1.99.1, < 3.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (~> 1.0, >= 1.0.1)
    ruby-progressbar (1.8.1)
    ruby_dep (1.3.1)
    rwr-redux (0.5.0)
      react_webpack_rails (>= 0.5.0)
    safe_yaml (1.0.4)
    sass (3.4.23)
    sass-rails (5.0.6)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    shellany (0.0.1)
    slack-notifier (1.5.1)
    slim (3.0.7)
      temple (~> 0.7.6)
      tilt (>= 1.3.3, < 2.1)
    slim-rails (3.1.2)
      actionpack (>= 3.1)
      railties (>= 3.1)
      slim (~> 3.0)
    slop (3.6.0)
    spring (1.7.2)
    sprockets (3.6.3)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.0)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    temple (0.7.7)
    therubyracer (0.12.3)
      libv8 (~> 3.16.14.15)
      ref
    thor (0.19.4)
    thread_safe (0.3.6)
    tilt (2.0.7)
    turbolinks (5.0.0)
      turbolinks-source (~> 5)
    turbolinks-source (5.0.0)
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (3.0.0)
      execjs (>= 0.3.0, < 3)
    unicode-display_width (1.1.0)
    values (1.8.0)
    vcr (3.0.3)
    warden (1.2.6)
      rack (>= 1.0)
    web-console (2.3.0)
      activemodel (>= 4.0)
      binding_of_caller (>= 0.7.2)
      railties (>= 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    webmock (2.3.1)
      addressable (>= 2.3.6)
      crack (>= 0.3.2)
      hashdiff
    websocket-driver (0.6.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.2)
    xpath (2.0.0)
      nokogiri (~> 1.3)
    zeus (0.15.4)
      method_source (>= 0.6.7)

PLATFORMS
  ruby

DEPENDENCIES
  awesome_print
  better_errors
  binding_of_caller
  bootstrap-sass (~> 3.3.6)
  byebug
  capybara
  coffee-rails (~> 4.1.0)
  coffeelint
  database_cleaner
  devise
  dotenv-rails
  ecto!
  factory_girl_rails (~> 4.0)
  faker
  font-awesome-sass (~> 4.6.2)
  foreman
  growl
  growlyflash (~> 0.8.4)
  guard
  guard-coffeelint
  guard-rspec
  guard-rubocop
  guard-zeus
  heroku-deflater
  honeybadger (~> 2.0)
  jbuilder (~> 2.0)
  jquery-rails
  jquery-turbolinks
  js-routes
  launchy
  material_girl!
  newrelic_rpm
  omniauth
  omniauth-oauth2 (~> 1.3.1)
  omniauth-salesforce
  paranoid2
  pg
  poltergeist
  pry
  puma
  rack-cors
  rails (~> 5.0)
  rails_12factor
  react_webpack_rails!
  restforce
  rspec-its
  rspec-rails (~> 3.5)
  rspec_junit_formatter (= 0.2.2)
  rubocop
  rwr-redux
  sass-rails (~> 5.0.6)
  sdoc (~> 0.4.0)
  slack-notifier
  slim-rails
  spring
  sprockets (= 3.6.3)
  turbolinks
  uglifier (>= 1.3.0)
  values
  vcr
  web-console (~> 2.0)
  webmock

RUBY VERSION
   ruby 2.3.1p112

BUNDLED WITH
   1.14.6

Package.json

{
  "private": true,
  "devDependencies": {
    "babel-eslint": "^6.1.0",
    "chai": "^3.5.0",
    "dotenv": "^4.0.0",
    "enzyme": "^2.4.1",
    "es6-promise": "^4.0.5",
    "eslint": "^2.13.0",
    "eslint-plugin-react": "^5.2.0",
    "expect": "^1.20.0",
    "jsdom": "^9.4.1",
    "mocha": "^2.5.0",
    "nock": "^8.1.0",
    "react-hot-loader": "^1.3.0",
    "redux-devtools": "^3.3.2",
    "sinon": "^1.17.4",
    "webpack-dev-server": "^1.14.0",
    "webpack-notifier": "^1.3.0"
  },
  "dependencies": {
    "babel-core": "^6.11.4",
    "babel-loader": "^6.2.0",
    "babel-plugin-transform-class-properties": "^6.11.5",
    "babel-polyfill": "^6.16.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.0",
    "babel-preset-stage-1": "^6.5.0",
    "classnames": "^2.2.5",
    "css-loader": "^0.23.0",
    "extract-text-webpack-plugin": "^1.0.0",
    "isomorphic-fetch": "^2.2.1",
    "node-sass": "^3.8.0",
    "numeral": "^1.5.3",
    "react": "^15.2.1",
    "react-addons-test-utils": "^15.3.2",
    "react-bootstrap": "^0.30.0",
    "react-bootstrap-typeahead": "^0.8.1",
    "react-dom": "^15.1.0",
    "react-onclickoutside": "^5.8.3",
    "react-redux": "^5.0.2",
    "react-webpack-rails": "^0.4.1",
    "redux": "^3.6.0",
    "redux-logger": "^2.8.1",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.2.0",
    "rwr-redux": "^0.4.0",
    "sass-loader": "^4.0.0",
    "sinon": "^1.17.5",
    "style-loader": "^0.13.1",
    "webpack": "^1.13.0",
    "webpack-notifier": "^1.3.1"
  },
  "scripts": {
    "build": "webpack -p --config webpack/production.config.js",
    "start": "webpack -w --config webpack/dev.config.js",
    "start-hot-dev": "webpack-dev-server --hot --inline --config webpack/hot-dev.config.js",
    "test": "mocha './spec/react/**/*.test.jsx' --compilers js:babel-core/register  --require ./spec/react/setup.js --recursive",
    "postinstall": "webpack -p --config webpack/production.config.js"
  },
  "license": "",
  "engines": {
    "node": ">= 4.4"
  }
}
twalpole commented 7 years ago

This is not a Poltergeist issue, it is correctly reporting the JS error that PhantomJS is returning. it is either an issue with your asset pipeline or it is an issue with PhantomJS.

Make sure your assets are getting rebuilt in the test environment so that RWR is actually defined in one of the JS files being loaded. If it is then the most likely reason is you have code utilizing ES2015+ features that is not being transpiled to ES5 (PhantomJS 2.1.1 only supports ES5 max)