Skip to content

Commit

Permalink
fixes lighthouse options + do not download chromium + can use chrome-…
Browse files Browse the repository at this point in the history
…stable
  • Loading branch information
jaymoulin committed Nov 15, 2017
1 parent 523db0e commit ab2fad9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1,589 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM femtopixel/google-lighthouse
MAINTAINER Jay MOULIN <[email protected]> <https://twitter.com/moulinjay>

USER root
RUN npm install -g google-lighthouse-puppeteer --unsafe-perm=true
#https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
RUN PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install -g google-lighthouse-puppeteer --unsafe-perm=true
USER chrome
RUN mkdir -p /home/chrome/testcases && cd /home/chrome
COPY entrypoint.sh /usr/bin/entrypoint
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

if [[ -f "/home/chrome/testcases/$1.js" ]]; then
lighthouse-puppeteer "/home/chrome/testcases/$1.js" $2
lighthouse-puppeteer "/home/chrome/testcases/$1.js" "{puppeteer:{executablePath: 'google-chrome'}}"
else
exec "$@"
fi
Expand Down
13 changes: 9 additions & 4 deletions lighthouse-puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class LighthousePuppeteer {
constructor() {
this.DEBUG_PORT = 9222;
this.puppeteer = require('puppeteer');
this.lightHouse = require('lighthouse-batch');
this.lightHouseBatch = require('lighthouse-batch');
this.defaultOptions = {
debugPort: this.DEBUG_PORT,
lighthouse: {
Expand All @@ -11,6 +11,11 @@ class LighthousePuppeteer {
out: '/home/chrome/reports',
html: true,
verbose: false,
},
puppeteer: {
args: [
`--remote-debugging-port=${options.debugPort}`
]
}
};
this.browser = null;
Expand All @@ -28,22 +33,22 @@ class LighthousePuppeteer {
console.log(`${modulePath}: Module incorrectly formatted. Module should have "getUrls" method!`);
process.exit(-4);
}
this.puppeteer.launch({args: [`--remote-debugging-port=${options.debugPort}`]})
this.puppeteer.launch(options.puppeteer)
.then(testcase.connect)
.then(b => new Promise((resolve) => {
this.browser = b;
resolve(b);
}))
.then(b => new Promise((resolve) => {
const options = {
const lighthouseOptions = {
verbose: options.lighthouse.verbose,
sites: testcase.getUrls(),
html: options.lighthouse.html,
out: options.lighthouse.out,
useGlobal: options.lighthouse.useGlobal,
params: `--port ${options.debugPort} ${options.lighthouse.params}`,
};
this.lightHouse(options);
this.lightHouseBatch(lighthouseOptions);
resolve(b);
}))
.then(b => b.close())
Expand Down
Loading

0 comments on commit ab2fad9

Please sign in to comment.