These are chat archives for opal/opal

4th
Apr 2016
Elia Schito
@elia
Apr 04 2016 00:12
@cj, thanks you uncovered a slight bug: 7f90297 should work now
opal/opal@7f90297
CJ Lazell
@cj
Apr 04 2016 00:14
@elia cheers. no problem. that's what bug magnets are for :)
Elia Schito
@elia
Apr 04 2016 00:16
that's a gift!
CJ Lazell
@cj
Apr 04 2016 02:20
https://github.com/mame/optcarrot opal pulling out the 0.02 fps :P
Mitch VanDuyn
@catmando
Apr 04 2016 03:08
Hello all... trying to use selenium capybara etc with chrome driver in an opal app. Immediately breaks chrome driver with this error:
Selenium::WebDriver::Error::UnknownError:
unknown error: Maximum call stack size exceeded
(Session info: chrome=49.0.2623.110)
(Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.10.5 x86_64)
so I made a simple rails app that does nothing but require opal (does not even do the Opal.load thing) and it still causes the problem. In otherwords just having the Opal code loaded on the page kills the chrome driver.
Problem seems to also occur on linux
Any clues what in the world Opal could be doing that would break chrome driver in this way? I am thinking that perhaps it redefines some JS builtin function?
Mitch VanDuyn
@catmando
Apr 04 2016 03:23
@/all I'm sure the above sounds perhaps obscure, but what it means is you can't do any integration or system testing with the ChromeDriver and Opal. Given that ChromeDriver is so much faster than Selenium+Firefox, I fear this might be a gotcha for opal adoption. This is way out of my wheel house, but I would even be willing to pay $$$ if somebody can get help get this understood and fixed.
Elia Schito
@elia
Apr 04 2016 07:22
@cj cool!
Brady Wied
@wied03
Apr 04 2016 14:38
@catmando - I don't use the Chrome driver but I've never had a problem with the capybara poltergeist, selenium, or webkit drivers. I went with poltergeist for most of my tests since it's faster than selenium/FFX.
Mitch VanDuyn
@catmando
Apr 04 2016 14:40
yeah that is what we use too. Chrome is just nice for debugging because you can see what is going on, the debugger is much nicer AND @fkchang has a prototype Opal debugger running in chrome. But from experience its about 20-30% faster than FF, and the chrome debugger is so much easier to use.
Mitch VanDuyn
@catmando
Apr 04 2016 15:47
@meh - I see you ran into this chrome issue already... did it ever get resolved? https://bugs.chromium.org/p/chromedriver/issues/detail?id=683
meh.
@meh
Apr 04 2016 15:51
@catmando not that I know
still broken
Mitch VanDuyn
@catmando
Apr 04 2016 16:03
okay I just posted an update using inline-reactive-ruby, so its a completely stand alone test case. @meh do you have any ideas on how we could isolate this (i.e. some how try with smaller and smaller sections of opal, until the problem disappears?)
Elia Schito
@elia
Apr 04 2016 16:05
@catmando looking again at the linked issue and its duplicates seems that it could be related to creating JS objects using Array(s) as their prototype and/or using RemoteWebDriver.findElementById
Mitch VanDuyn
@catmando
Apr 04 2016 16:06
@elia - but note that the error happens when doing something as simple as driver.execute_script("true") which does not even return its value...
Elia Schito
@elia
Apr 04 2016 16:08
@catmando yeah, well, I just browsed the chromedriver issue, but have no direct experience with it :\
Mitch VanDuyn
@catmando
Apr 04 2016 16:08
On my machine, I chopped out stuff until I was left with just opal.js. If its included BAM problem. Nothing has to be called (including Opal.load) just loading the script kills chrome driver
@elia - yeah understood.
Elia Schito
@elia
Apr 04 2016 16:08
@catmando can you provide me with a very simple project with gemfile that reproduces it
?
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Inline Reactive Ruby Demo</title>
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="https://rawgit.com/reactive-ruby/inline-reactive-ruby/master/inline-reactive-ruby.js"></script>

    <script type="text/ruby" src="clock.rb"></script>

    <script type="text/ruby">
      Element["#clock"].render { Clock() }
    </script>

  </head>
  <body>
    <div id="clock"></div>
    <div>The time brought to you by <a href="https://github.com/reactive-ruby/inline-reactive-ruby">inline-reactive-ruby</a></div>
  </body>
</html>
no gem file needed :-)
Elia Schito
@elia
Apr 04 2016 16:11
@catmando not very familiar with chrome driver, any gem I can install or command to run?
Mitch VanDuyn
@catmando
Apr 04 2016 16:11
hang on...
I think all you need is this:
gem 'chromedriver-helper'
Mitch VanDuyn
@catmando
Apr 04 2016 16:18
FYI - to simplify things (perhaps) the same problem arises at http://opalrb.org/try/
(which does not include reactive-ruby and some other stuff)
Mitch VanDuyn
@catmando
Apr 04 2016 16:29
ha! and now to narrow it down even more:
require 'selenium/webdriver'
driver = Selenium::WebDriver.for :chrome
# grab any old insecure page that happens to have jQuery it
driver.navigate.to "http://www.webdesignerdepot.com/2010/07/20-demos-showing-advanced-jquery-effects/"
driver.execute_script("true")  # works fine
# now load opal
driver.execute_script("jQuery.getScript('http://cdn.opalrb.org/opal/current/opal.min.js')")
# now it will break!
driver.execute_script("true")
meh.
@meh
Apr 04 2016 16:56
@catmando I did try to make a reduced test case at the time, when Opal was much smaller, no luck
CJ Lazell
@cj
Apr 04 2016 16:59
@catmando if you need the increased speed I'd go with phantomjs, I know that works
Mitch VanDuyn
@catmando
Apr 04 2016 17:10
@cj thanks - that is what we use to run tests, but we also find during development an actual browser is nice to see what is going on, and to run the console.
CJ Lazell
@cj
Apr 04 2016 17:11
@catmando you can run a remote console with phantomjs :) also if you want to see what the site looks like at certain stages you can also take screenhots
you can also capture video if you want
it's nice too because I know phantomjs and chromedriver act differently in some cases. so if you test locally with chromedriver and then push to a CI that uses phantomjs; tests that you think will pass might actually fail
Mitch VanDuyn
@catmando
Apr 04 2016 17:14
oh yeah I am with you there...
we basically write the test, run with firefox while developing, then switch to poltergeist before pushing.
but I did not know about video
Mitch VanDuyn
@catmando
Apr 04 2016 17:33

@/all - so its this line in opal that kills chrome driver: self.$require("opal/mini");

If i comment that line out, chrome driver works! What opal/mini (mini test?)

Elia Schito
@elia
Apr 04 2016 17:34
no, it's the mini-core that stands by itself
@catmando can you try with opal/base?
Brady Wied
@wied03
Apr 04 2016 17:38
@catmando - That's one reason why I think the unit test approach is better. Trying to debug unit level code with an integration test just seems a little goofy to me.
@catmando - shameless plug: and with both the stock opal-rspec Rack runner to an extent and with karma-opal-rspec, you can debug, set breakpoints, etc. in Chrome
Mitch VanDuyn
@catmando
Apr 04 2016 17:42
@elia - narrowed down to "corelib/array"
Elia Schito
@elia
Apr 04 2016 17:43
Let me bet on adding stuff to the array prototype, and possibly some incaution use of for … in
gonna check their source now
Mitch VanDuyn
@catmando
Apr 04 2016 17:49
@wied03 - we are doing unit tests. Just driving from capybara. Certainly love opal-rspec and use it as well. You are probably right, but I am enjoying pushing the envelope a bit. Set a time that we can chat on a hang out, and we can go over one of our components, and compare how we would test. Let me know a time that works for you to chat.
@elia are you checking chromedriver source? I will keep trying to narrow it down in Opal...
Elia Schito
@elia
Apr 04 2016 17:50
@catmando still searching for their repo :joy_cat: and must stop for dinner now :)
Mitch VanDuyn
@catmando
Apr 04 2016 17:50
@wied03 and regardless, of whether I am goofy or not, sooner or later people WILL want to do intergration and acceptance tests with ChromeDriver.
:fork_and_knife:
Elia Schito
@elia
Apr 04 2016 17:51
:spaghetti: :yum:
Brady Wied
@wied03
Apr 04 2016 17:51
@catmando - Don't worry, you are not personally goofy (that I know of :).
Mitch VanDuyn
@catmando
Apr 04 2016 17:51
:-)
Brady Wied
@wied03
Apr 04 2016 17:51
yes, it should work irrespective of what i
i'm saying
CJ Lazell
@cj
Apr 04 2016 17:51
@catmando ever seen how meteorjs do their tests? they run in the browser as you work (client and server tests) I'm building something right now that does the same with opal :)
Brady Wied
@wied03
Apr 04 2016 17:52
@cj - Sorry to keep beating this drum, but you do realize k-o-r already does that to an extent, right ?
CJ Lazell
@cj
Apr 04 2016 17:52
k-o-r?
Brady Wied
@wied03
Apr 04 2016 17:53
I'm working on some ways to improve it and If I have more eyes to help, it would be usful
karma-opal-rspec
Mitch VanDuyn
@catmando
Apr 04 2016 17:53
nope - hence my request that we chat a bit this, so maybe you can set me straight.
Brady Wied
@wied03
Apr 04 2016 17:54
@cj - If you don't want to use Karma, then it obviously doesn't help you, but it might
CJ Lazell
@cj
Apr 04 2016 17:55
@wied03 interesting. I try to do things with as less deps as possible. I'm using https://github.com/djanowski/cutest for my tests
I love opal rspec, but it's not 0.10.0 ready and I hate not being able to control that :)
Brady Wied
@wied03
Apr 04 2016 17:56
@cj - well opal-rspec is certainly not the lightest of frameworks. It's a question of whether someone needs/wants the value of rspec
as to 0.10, we're not far off. Some recent commits broke it
CJ Lazell
@cj
Apr 04 2016 17:58
yee, I know... I made an issue about it. but I think you got confused my issue :)
Brady Wied
@wied03
Apr 04 2016 17:58
@cj - I did pose a question to you on the issue, if you want to clarify, feel free
CJ Lazell
@cj
Apr 04 2016 18:00
replied. if you need help testing the latest version let me know
@wied03 with karma-opal-rspec can you still inject html before the start of each test?
Brady Wied
@wied03
Apr 04 2016 18:05
@cj - I suppose you could but I'd say it's more dependent on Jasmine/Mocha/etc. I usually write React tests with it and the React test utils handle the DOM stuff. If you weren't testing React, you could use opal-jquery or raw DOM stuff in RSpec before hooks as much as you wanted
In this case, opal-rspec is on the same level as Jasmine/mocha
this karma plugin started as an experiment and I laid out a plan, if it's a useful thing, to split it into several parts
CJ Lazell
@cj
Apr 04 2016 18:08
yee, I think it would be. I use webpack. I'll have to give it a go once opal-rspec works with 0.10.0
Brady Wied
@wied03
Apr 04 2016 18:08
Yeah, right now it's not webpack friendly because it assumes sprockets is in control. one of the ideas, if people want it, is to separate that out
CJ Lazell
@cj
Apr 04 2016 18:29
I'd use it if it was separted out :)
Brady Wied
@wied03
Apr 04 2016 18:30
OK, I noted that (wied03/karma-opal-rspec#20). When I finish some of the current refactoring, it might be doable
CJ Lazell
@cj
Apr 04 2016 19:13
awesome :)
sooo I just tried require 'opal-parser' in 0.10.0, I'm getting this error https://gist.github.com/7f957c23423b80c0d3af086e236b838a
Elia Schito
@elia
Apr 04 2016 20:22
@cj which command? works fine here:
⤑ opal -v -ropal-parser -e 'eval "puts 5"'                                                                                                                                       ~
Opal v0.10.0.beta2
5
⤑                                                                                                                                                                                ~
CJ Lazell
@cj
Apr 04 2016 20:36
@elia yee, I think it's to do with opalrb-loader rather than opal
Mitch VanDuyn
@catmando
Apr 04 2016 23:14
@cj - I missed your comment previous about meteorjs.... That is what I would like to have. My conclusion is to make it work in general the tests have to be driven from the server. So to do unit tests for client side components, I have a "mount_component" helper that will run a code block on the client side, but sets up and monitors the test as part of the normal rspec script. Nobody except for me :-) is convinced this is worth doing, but I just figure its fun to try :-)
Brady Wied
@wied03
Apr 04 2016 23:39
@catmando - I think your point about factory girl, etc., given your architecture, is a better reason. Karma watches files just fine and forces the browsers it's controlling to re-run tests.