-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as a developer i want to run my JS tests using phantomJS (or similar headless browser) so they run faster #105
Comments
Jan has done a spike with this and seems to have had good results. Key files below, original src at https://stash.caplin.com/projects/TP/repos/cutlass_phantomjs/browse phantom_browser.js
README.md
|
AndyL has also used PhantomJS with BRJS:PhantomJS is a headless web-kit which is useful for running things like unit tests without starting up a whole browser. We have at least one client who's using it & it's compatible with CT3/bladrunner so here's some steps to get it working:
Credit: PhantomJS runner:
|
Nice work everyone :-) we can put this in once we get CT integration out the door. |
I'd like to see us addressing this with a Java-focus. We know there are tools available in the node.js world and integration should be relatively easy. But what about those that don't and can't use node.js? |
I dont think this is Node based, it looks likes its a native binary. From http://phantomjs.org/download.html
|
It's not node. |
Ok, my bad.
I stand by this. |
Hi, We already use this method with the non-open-source version of bladerunner. We find that depending on the amount of tests and the computer it is run on, bladerunner (or js test driver) hangs very often. I suspect it is js test driver and there is nothing you can do about it, but something to think about. Once CT is using this project I can report back on whether it is still hanging (on our bamboo CI server it hangs 1 in 3-5 builds). I uploaded logs to SDANSDPL-158 if they bear any relation. I'm also hoping that its js-test-driver and that switching to karma may allow us to do headless testing without hangs. |
Hi @lukeapage, yes the hanging is definitely js-test-driver related, as we've also seen the same thing when running the tests directly with js-test-driver (no BladeRunner involved). I've met a couple of people in the past who abandoned js-test-driver in favor of Karma for exactly this reason, and we need to do the same. |
Great, sounds like a plan. |
Once #857 is merged in (probably ready for a v0.12 release) PhantomJS will be part of the standard BRJS release and will be configured to be the default browser. |
Just gave this a go. Works nicely. But... one issue: when running without a browser the stack trace for failing tests is not as useful. e.g. phantom mode:
with chrome:
One other thing, phantomJS adds 50 meg to our distribution zip:( discuss |
I don't think theres much we can do here given it's the browser generating the call stack. IMO its a reasonably minor thing since its easy to run the tests in another browser to debug.
Pros: we have a default browser which massively simplifies the onboarding process (keeping @leggetter happy 😄) IMO this isn't a huge deal since BRJS only needs to be downloaded once (for a given version) and nowadays people have a good enough connection to download 100meg. |
We should probably have something somewhere which states what's in the zip. On the FAQ page? "Why is BRJS ~100MB?". If we get complaints about the size we could look at alternatives e.g.:
|
@andyberry88 some banks have 100meg single download restrictions, so to get this zip they'll need to go through red tape or resort to sneaky means to download it in chunks. So pushing our dist zip back over 100meg may reduce our 'blue chip' trialists |
So just to be clear, it's slower, has less readable call stacks, makes BRJS less portable (won't work on Solaris or BSD for example, I'm just saying), doesn't have any debugging tools, and increases our download size, for the single benefit that it doesn't open up a window while test are running? @andyberry88 is there a reason why in the past we ddn't distribute Chromium, since that would also have solved the usability problem of having to configure a browser before running tests? |
@thecapdan oh yeah, I'd forgetten about that. That used to happen at a bank where I was working too, so that installing Eclipse JEE was a major faff. |
I don't agree with this, I've seen tests execute ~ 15% faster.
Yep, I'll accept that one.
I doubt this is something we're ever going to have issues with..... The fact that it doesn't open a separate window is a massive win. The reason we haven't shipped with other browsers (and that most can be unreliable) is they all have local profiles that are used. This means any crashes that happen in one session can ofter spill over (warnings etc) in to the next session. We don't see this issue with our build since it forces the browsers to use fresh profiles which the build recreates each time - this isn't something a general user of BRJS will have.
I can see this as an issue. Perhaps we need 2 distributions as @leggetter suggested. I don't think the prompt to download would work since that would presumably be an issue for banks too. |
IMO you don't want to include phantomjs. What happens when a new version of phantomjs comes out? If i update BRJS but phantomjs hasn't updated do I want to have to re-download it? For people who would check-in BRJS as part of the development environment, should they have to check in phantomjs too? If BRJS was a node package you would have dependencies that would just install (there is a node phantom package which includes the latest phantom) - have you thought about using some other package manager to enable users to configure and download multiple dependencies without including it all in one zip? w.r.t.stack traces - we don't find it a problem, we use phantom for our CI server and locally to avoid having to give chrome focus (because we have a few tests that rely on focus) but if we get a problem that means we need to debug we switch to chrome. Very rarely will a problem in tests be made more obvious by the stack and not involve debugging. For our CI server - we wish we didn't use phantom, because we now have over 3000 uts and ats and it means phantom fails over half the time. We're looking forward to getting support for karma. Have you had any luck running chrome as a service with bladerunner as an alternative to phantom in CI builds? |
Hi @lukeapage, lot's of good points here. One point of confusion though; can you please provide more background detail as to why we might want to run Chrome as a service to be able to use Chrome on CI? We've been running Chromium, Firefox & IE on our CI boxes since the beginning without incident. We originally tried Chrome instead of Chromium but it caused issues on developer boxes where Chrome might already have been running, but I can't remember there being any other issues with it. |
(Damn, @dchambers beat me to it 😄) Thanks for the input @lukeapage, I'm not sure what the answer is here since IMO there are huge pros and cons either way. One of the problems we've had up until now is we've found it difficult to provide a template test-runner.conf with accurate browser paths since they could be wildly different on each developer machine. This isn't a problem for developers comfortable with using BRJS but it's another step in the on-boarding process and our getting started guide then has another concept to introduce. If we shipped with a browser where we knew the path running tests would work out of the box.
Since it's just a test runner configuration the path to the PhantomJS could be updated to use a locally installed version. This would be the same if we updated PhantomJS and a developer prefered to stay on the version they were using previously.
If BRJS is checked in I'd imagine they would also include PhantomJS. This isn't ideal and IMO we should remove the need for BRJS to be checked in at all. One of my pet hates is binaries checked in to source control but unfortunately that's the easiest way to make it work at the moment. One way to go with this would be to do something similar to Gradle where they have a Gradle wrapper (http://www.gradle.org/docs/current/userguide/gradle_wrapper.html). The wrapper itself and a small amount of config is checked in and it deals with downloading the required version of Gradle. This makes it very easy to switch between Gradle versions and test updates.
Integrating package managers in to BRJS is one thing we hope to look at in the coming months although we'd thought about making use of it for library dependencies (jQuery, Knockout etc.). Using it as part of core BRJS to allow commands and plugins to download dependencies is an interesting idea.
One of the aims for the build is to keep the dev build as close as possible to the CI build. We've had a huge amount of pain in the past where the only way to debug something was to go on to the CI box which in turn caused more problems for builds running after. General brain dump of where we are so far with the 'is PhantomJS part of the BRJS zip' question:
|
@andyberry88 so is the reason @lukeapage and other external developers will see greater value to using PhantomJS than we do is because the If this was converted into a BRJS command, would not that not also solve the initial download size problem, the browser paths problem and the fact that others are struggling to get browsers reliably working in their CI environments? For example, to perform a full download the user could type:
which would download the relevant PhantomJs, Chromium and Firefox for their platform, and configure their 'test-runner.conf' to make use of these browsers. Whereas to refresh the profiles of already downloaded browsers the user could type:
Users following the tutorials could then be instructed to run this command before attempting to run any tests, and the build scripts people create for their CI could use these scripts to ensure they have correctly configured browsers available to test with. Finally, developers at banks that may have to connect via a proxy, would be aware that the |
Hrmm, Well I tried it with chrome and it does work (though with the following errors)
but speaking to the @chrisprice he thought that it didn't work if the account was a proper service account (we are temporarily running our CI server under a normal user account) - it would be good to know if you did or didn't have any problems with this. |
Hi @lukeapage, Those Chrome errors can be ignored, and I think in the current BRJS code you won't even see those kinds of errors anyway. We use a browser path like this, which uses the
and perhaps this makes it work regardless of what user is logged in? @andyberry88 might that be true? |
It's the For the time being we'll remove PhantomJS as a browser shipped with BRJS and just use it within our build. I like the commands suggested by @dchambers but these probably need some thought before we look at tackling them. Moving back into the backlog, update to follow... |
Closed in error after merging #939 |
alot of testing libraries are using things like phantomJS to run JS tests. it would be nice if we can support headless browsers and use these by default in the BRJS build - we can still use 'real' browsers in CI.
(this may already be possible, noting it down so we can keep track of it)
The text was updated successfully, but these errors were encountered: