Skip to content

Commit

Permalink
feat: allow publishing the generated html repo (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah committed Apr 21, 2021
1 parent e99afa0 commit 53886d5
Show file tree
Hide file tree
Showing 15 changed files with 12,373 additions and 6,330 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ module.exports = {
parserOptions: {
ecmaVersion: 11,
},
overrides: [
{
files: ['cypress/**/*.js'],
parserOptions: {
sourceType: 'module',
},
env: {
'cypress/globals': true,
},
plugins: ['cypress'],
},
],
};
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ node_modules
.vscode
yarn-error.log
# Local Netlify folder
.netlify
.netlify
reports
cypress/videos
cypress/screenshots
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Then add the plugin to your `netlify.toml` configuration file:
best-practices = 0.9
seo = 0.9
pwa = 0.9

# optional, deploy the lighthouse report to a path under your site
[plugins.inputs]
output_path = "reports/lighthouse.html"
```

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

# you can specify output_path per audit, relative to the path
output_path = "reports/route1.html"

# to audit a specific absolute url
[[plugins.inputs.audits]]
url = "https://www.example.com"
Expand Down
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
16 changes: 16 additions & 0 deletions cypress/integration/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('Generates Lighthouse reports', () => {
it('Verify report on root path', () => {
cy.visit('/reports/lighthouse.html');
cy.contains('Performance');
});

it('Verify report on route1', () => {
cy.visit('/route1/reports/route1.html');
cy.contains('Performance');
});

it('Verify report on route2', () => {
cy.visit('/route2/reports/lighthouse.html');
cy.contains('Performance');
});
});
1 change: 1 addition & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = () => {}
Empty file added cypress/support/index.js
Empty file.
4 changes: 4 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
required: false
description: Key value mapping of thresholds that will fail the build when not passed.

- name: output_path
required: false
description: Path to save the generated HTML Lighthouse report

- name: audits
required: false
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.
13 changes: 13 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@ NODE_VERSION = "15"
[[plugins]]
package = "./src/index.js"

[plugins.inputs]
output_path = "reports/lighthouse.html"

[plugins.inputs.thresholds]
performance = 0.9

[[plugins.inputs.audits]]
output_path = "reports/route1.html"
path = "route1"
[[plugins.inputs.audits]]
path = "route2"
[[plugins.inputs.audits]]
path = ""

[[plugins]]
package = "netlify-plugin-cypress"
# do not run tests after deploy
[plugins.inputs]
enable = false
# run tests after build
[plugins.inputs.postBuild]
enable = true
Loading

0 comments on commit 53886d5

Please sign in to comment.