-
Notifications
You must be signed in to change notification settings - Fork 121
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
Add support for headless Chrome/ChromeCanary #111
Conversation
Thank you, I'm generally not opposed to merge this, but I would like some docs saying that it is experimental and where to look for details about it. |
It would also be great if we could add it to travis and test it there if that's possible |
expect(headlessGetOptions.call(context, url, args, parent)).to.be.eql([ | ||
'-incognito', | ||
'--headless', | ||
'--disable-gpu', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curiosity: What are the pros of using incognito and disable-gpu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--disable-gpu
is currently needed with headless because of linking errors with osmesa.so. That will hopefully not be required once Chrome switches to their SwiftShader library as a software rendering engine. See https://bugs.chromium.org/p/chromium/issues/detail?id=617551 for details.
-incognito
is just an example flag in the test, ensuring that it gets passed through.
@dpogue thanks for this PR! I am using your repo/branch for karma-chrome-launcher but I am getting the following Error inside my docker container. Any Ideas what might be causing the
|
That sort of error seems to be common if you ran the npm install with sudo and are trying to run the karma command without sudo. Maybe try a chown/chmod on your node_modules folder? |
I figured it out.. It was related to my env variable that I had set, Once I removed it it worked fine. |
I can confirm that in my case it worked without issues. I used it for unit testing. Great work, thanks @dpogue 👍 |
name: 'ChromeHeadless', | ||
|
||
DEFAULT_CMD: { | ||
// Try chromium-browser before chromium to avoid conflict with the legacy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is out of date, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, yes it is (although it is also out-of-date further up in the file where I copied this block from)
My simpler Jenkins setup likes this. 👍 |
For those who are wanting to use this before it's merged, you can tell npm to install it from the git branch: Headless Chrome is supported in Chrome 59 on Linux and Mac. Windows is not supported yet (they're aiming for Chrome 60). See https://developers.google.com/web/updates/2017/04/headless-chrome for more info about headless chrome. I have added tests to the PR, and will try to get some docs written. |
@dignifiedquire I think we're good to merge this. Do you agree? |
Thank you everyone 🎉 |
Will it be a new release soon? |
@rogeriopvl I can cut a new release, but maybe this should be fixed first #120? |
@dignifiedquire #120 doesn't sound at all related with karma-chrome-launcher. |
@dignifiedquire #120 is not a bug, it will fail like that for people trying this with current stable Chrome, i.e. v58 (and maybe even with v59 on Windows as there it will be officially supported only in v60 & newer). |
Okay will do a release then |
done 2.1.0 |
Will this work with Bamboo CI? I changed my karma config from:
to
but it seems to be failing now. Also, does this default to phantomjs if chrome headless fails? |
Tested on Linux with
google-chrome-unstable
, but as of today it should be support in macOS Chrome Canary as well.Not really expecting this to be merged until headless support hits a stable release across multiple OSes, but figured I'd open a PR for anyone trying to figure out how to get it working. I was thinking of publishing it to npm as
karma-headless-chrome-launcher
, but it seems that name is already in use.