Live data from Hacker News

Headless mode in Firefox

developer.mozilla.org

41–50 of 191 posts

Re: Headless mode in Firefox

#41

For all of you old fogies working on angular 1 apps and are running browser tests with karma you can run your tests in firefox with headless mode with a customer launcher. Add the snippet below to your karma conf ``` browsers: ['FirefoxHeadless'], customLaunchers: { FirefoxHeadless: { base: 'Firefox', flags: [ '-headless', ], }, }, ``` Note you need to be running the beta version of firefox, I needed to download it f…

Does this offer any real benefit over Xvfb?

Well currently we run the karma tests on CI with chrome headless so this allows us to do the same with firefox

Re: Headless mode in Firefox

#42
post #29

This is very nice. What's the recommended way to run end-to-end tests in headless firefox _and_ headless chrome? Can't wait for a cross-platform headless Edge :-)

I'm currently evaluating testcafe which is pretty nice, and headless chrome was easy to setup. I'm interested to see what people recommend for browser testing, I'm also using preact.

I switched from selenium to testcafe a few weeks ago. It's such a great tool. I would never go back.

Re: Headless mode in Firefox

#43

For all of you old fogies working on angular 1 apps and are running browser tests with karma you can run your tests in firefox with headless mode with a customer launcher. Add the snippet below to your karma conf ``` browsers: ['FirefoxHeadless'], customLaunchers: { FirefoxHeadless: { base: 'Firefox', flags: [ '-headless', ], }, }, ``` Note you need to be running the beta version of firefox, I needed to download it f…

Do you have any advice on how to get off of Karma with Angular 1 apps?

Well why do you want to do that, if you are finding the tests are too slow it maybe worth writing some tests with jasmine that can be run in node without a browser.

That's what we currently do, karma and browser testing are useful but sometimes you can get away with not using them.

One thing we are trying is using JSDom to run browser based tests in node

Re: Headless mode in Firefox

#44
post #36

Earlier quoted context omitted.

Don't know about performance numbers, but one reason for headless browsers is so that you can run your tests on cheap small headless Linux servers.

Adding to ^. You don't need to have the Xorg stuff running to run tests.

That's what Xvfb is for.

"xvfb-run firefox" and "firefox -headless" should be functionally equivalent. But I would still be interested in performance comparison with numbers.

Re: Headless mode in Firefox

#45

For all of you old fogies working on angular 1 apps and are running browser tests with karma you can run your tests in firefox with headless mode with a customer launcher. Add the snippet below to your karma conf ``` browsers: ['FirefoxHeadless'], customLaunchers: { FirefoxHeadless: { base: 'Firefox', flags: [ '-headless', ], }, }, ``` Note you need to be running the beta version of firefox, I needed to download it f…

Does this offer any real benefit over Xvfb?

We were using Xvfb with PhantomJS. Moving to a headless browser gave us the advantage of making sure everything is rendering just as we see in the GUI mode of that browser. This had a lot to do with moving away from PhantomJS. But it also removed the unkowns, Xvfb and other dependencies that came with it, from our stack. The lesser the unkowns the better I guess.

Re: Headless mode in Firefox

#46
post #34
post #6

Can you tell Firefox to print in headless mode? I want to write reports using HTML and JS, but printing is always an issue.

Remember that if you pass through any data from an outside source, you're running their code on your browser when you thought you were just printing a document. The security issues don't apply in all circumstances, of course, but if you feel like taking a shortcut to PDF generation and printing through a headless browser, you need to keep them in mind.

Rendering a PDF you got some other way is also "Running their code", just in a different sandbox :-)

Re: Headless mode in Firefox

#47
post #29

This is very nice. What's the recommended way to run end-to-end tests in headless firefox _and_ headless chrome? Can't wait for a cross-platform headless Edge :-)

I'm currently evaluating testcafe which is pretty nice, and headless chrome was easy to setup. I'm interested to see what people recommend for browser testing, I'm also using preact.

Writing end-to-end tests is always a sucky and flaky experience, and it always ends up slowing down CI. With that said, I've used testcafe without any big complaints.

My general rule of thumb is to try having as few end-to-end tests as possible. It's fine for an e2e test to cover multiple aspects of your application. Trying to write e2e tests as if they were unit tests just leads to sadness and infinite CI builds.

I don't think there's any value to running all your tests on the browser. It's much faster and simpler to run the bulk of your tests on node, with a fake DOM environment.

If you're interacting directly with the DOM, you might want to consider breaking that off as a separate lib. From the lib's repo you can have all of its tests run on a real browser.

Re: Headless mode in Firefox

#49
post #6

Can you tell Firefox to print in headless mode? I want to write reports using HTML and JS, but printing is always an issue.

If you need professional typesetting from HTML+CSS, Prince XML is still king, I'm pretty sure. It can be invoked & run heedlessly.

It also supports page-oriented CSS declarations and variables, like headers, footers, page numbers, etc.

Re: Headless mode in Firefox

#50

For all of you old fogies working on angular 1 apps and are running browser tests with karma you can run your tests in firefox with headless mode with a customer launcher. Add the snippet below to your karma conf ``` browsers: ['FirefoxHeadless'], customLaunchers: { FirefoxHeadless: { base: 'Firefox', flags: [ '-headless', ], }, }, ``` Note you need to be running the beta version of firefox, I needed to download it f…

> Note you need to be running the beta version of firefox

Also note that that's only the case on Windows and OS X (it's already released for Linux), and only as long as Firefox 56 hasn't been released yet :)

Post reply on HN