@genexus/lighthouse-inspector
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -10,3 +10,3 @@ function evalExpectation (expectedScore, score) { | ||
module.exports = function (results, expectations){ | ||
module.exports = function (results, expectations = {}){ | ||
let error = false; | ||
@@ -13,0 +13,0 @@ let messages = []; |
@@ -46,2 +46,3 @@ # Configuration | ||
| lighthouseParams | <code>Object|undefined</code> | | ||
| failOnUnmetExpectation | <code>boolean</code> | | ||
@@ -74,1 +75,5 @@ ### `pages: string[]` | ||
| flags | <code>Object</code> | An object containing Lighthouse flags, as specified in the [Lighthouse CLI options](https://github.com/GoogleChrome/lighthouse#cli-options) | | ||
### `failOnUnmetExpectation: boolean` | ||
The `failOnUnmetExpectation` property indicates whether the program will return with an error code when an expectation is unmet. Defaults to `false`. |
16
index.js
@@ -25,15 +25,15 @@ const path = require('path'); | ||
function inspectPages (pending, expectations = {}, lighthouseParams = {}) { | ||
function inspectPages (pending, opts) { | ||
if (pending.length > 0) { | ||
const [url] = pending; | ||
const { flags, config } = lighthouseParams; | ||
const { expectations, lighthouseParams = {} } = opts; | ||
console.log(`Running lighthouse test on ${url}`); | ||
launchChromeAndRunLighthouse(url, flags, config).then(results => { | ||
launchChromeAndRunLighthouse(url, lighthouseParams.flags, lighthouseParams.config).then(results => { | ||
const analyzerResult = analyzer(results, expectations); | ||
if (analyzerResult.error) { | ||
if (opts.failOnUnmetExpectation && analyzerResult.error) { | ||
process.exitCode = 1; | ||
} | ||
logAnalyzerResult(analyzerResult); | ||
inspectPages(pending.slice(1), expectations, lighthouseParams); | ||
inspectPages(pending.slice(1), opts); | ||
}); | ||
@@ -44,4 +44,4 @@ } | ||
module.exports = (configPath) => { | ||
const config = JSON.parse(fs.readFileSync(configPath)); | ||
const { pages, expectations, lighthouseParams } = config; | ||
const opts = JSON.parse(fs.readFileSync(configPath)); | ||
const { pages } = opts; | ||
@@ -52,3 +52,3 @@ if (pages.length === 0) { | ||
} | ||
return inspectPages(pages, expectations, lighthouseParams); | ||
return inspectPages(pages, opts); | ||
}; |
{ | ||
"name": "@genexus/lighthouse-inspector", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Run Google Lighthouse on a set of URLs, specifying expectations", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,4 +13,6 @@ # lighthouse-inspector | ||
``` | ||
```sh | ||
npm install -g @genexus/lighthouse-inspector | ||
# or | ||
npm install --save-dev @genexus/lighthouse-inspector | ||
``` | ||
@@ -26,3 +28,3 @@ | ||
When an expected score isn't met, a message explaining the error is shown and the program returns with an error. | ||
When an expected score isn't met, a message explaining which category or audit didn't meet the expected score. | ||
@@ -29,0 +31,0 @@ ## Running the tests |
@@ -24,3 +24,4 @@ { | ||
} | ||
} | ||
}, | ||
"failOnUnmetExpectation": false | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
471672
7435
42