Skip to content

Commit 53886d5

Browse files
authored
feat: allow publishing the generated html repo (#180)
1 parent e99afa0 commit 53886d5

15 files changed

+12373
-6330
lines changed

.eslintrc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,16 @@ module.exports = {
1313
parserOptions: {
1414
ecmaVersion: 11,
1515
},
16+
overrides: [
17+
{
18+
files: ['cypress/**/*.js'],
19+
parserOptions: {
20+
sourceType: 'module',
21+
},
22+
env: {
23+
'cypress/globals': true,
24+
},
25+
plugins: ['cypress'],
26+
},
27+
],
1628
};

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ node_modules
33
.vscode
44
yarn-error.log
55
# Local Netlify folder
6-
.netlify
6+
.netlify
7+
reports
8+
cypress/videos
9+
cypress/screenshots

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Then add the plugin to your `netlify.toml` configuration file:
2727
best-practices = 0.9
2828
seo = 0.9
2929
pwa = 0.9
30+
31+
# optional, deploy the lighthouse report to a path under your site
32+
[plugins.inputs]
33+
output_path = "reports/lighthouse.html"
3034
```
3135

3236
By default, the plugin will serve and audit the build directory of the site.
@@ -44,6 +48,9 @@ You can customize the behavior via the `audits` input:
4448
[[plugins.inputs.audits]]
4549
path = "route1"
4650

51+
# you can specify output_path per audit, relative to the path
52+
output_path = "reports/route1.html"
53+
4754
# to audit a specific absolute url
4855
[[plugins.inputs.audits]]
4956
url = "https://www.example.com"

cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

cypress/integration/e2e.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
describe('Generates Lighthouse reports', () => {
2+
it('Verify report on root path', () => {
3+
cy.visit('/reports/lighthouse.html');
4+
cy.contains('Performance');
5+
});
6+
7+
it('Verify report on route1', () => {
8+
cy.visit('/route1/reports/route1.html');
9+
cy.contains('Performance');
10+
});
11+
12+
it('Verify report on route2', () => {
13+
cy.visit('/route2/reports/lighthouse.html');
14+
cy.contains('Performance');
15+
});
16+
});

cypress/plugins/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = () => {}

cypress/support/index.js

Whitespace-only changes.

manifest.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
required: false
1010
description: Key value mapping of thresholds that will fail the build when not passed.
1111

12+
- name: output_path
13+
required: false
14+
description: Path to save the generated HTML Lighthouse report
15+
1216
- name: audits
1317
required: false
1418
description: A list of audits to perform. Each list item is an object with either a url/path to scan and an optional thresholds mapping.

netlify.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,25 @@ NODE_VERSION = "15"
88
[[plugins]]
99
package = "./src/index.js"
1010

11+
[plugins.inputs]
12+
output_path = "reports/lighthouse.html"
13+
1114
[plugins.inputs.thresholds]
1215
performance = 0.9
1316

1417
[[plugins.inputs.audits]]
18+
output_path = "reports/route1.html"
1519
path = "route1"
1620
[[plugins.inputs.audits]]
1721
path = "route2"
1822
[[plugins.inputs.audits]]
1923
path = ""
24+
25+
[[plugins]]
26+
package = "netlify-plugin-cypress"
27+
# do not run tests after deploy
28+
[plugins.inputs]
29+
enable = false
30+
# run tests after build
31+
[plugins.inputs.postBuild]
32+
enable = true

0 commit comments

Comments
 (0)