We are moving from PhantomJS to ChromeHeadless in our testing environment with Karma & Jasmine for our frontend Node.js app. Locally, it is just necessary to replace the field
browsers: ['PhantomJS'],
with
browsers: ['ChromeHeadless'],
and add the entry in the package.json:
"karma-chrome-launcher": "x.y.z",
Then the npm build will take the locally installed chrome browser instance to run the Jasmine tests. This works correctly.
On our jenkins build server (which runs on Debian Jessie), there is no chrome installed, so the tests cannot be executed.
Now the question:
- Is there an NPM package for chrome , which I can install, so that I don't have to install it on the debian machine directly? (Similar to phantomjs-prebuilt, which installs the current PhantomJS instance before running the actual test case)
UPDATE: Yes, there is the NPM package puppeteer, see: https://github.com/GoogleChrome/puppeteer. This will fetch a chrome version depending on the current build machine. Therefore a new entry the package.json file must be added (or installed via npm install puppeteer -D):
"puppeteer": "x.y.z",
and the karma.conf:
process.env.CHROME_BIN = require('puppeteer').executablePath();
browsers: ['HeadlessChrome'],
customLaunchers: {
HeadlessChrome: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
Be aware that with Debian, there sometimes must be installed missing dependencies. See: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md