Automated Testing for Hugo site
Install and Usages
npm install test-hugo --save-dev
Sample package.json
:
Usages
npm run test-hugo -- --add-snapshot <PATH>
npm run test-hugo -- --htmlproofer <true|false>
npm run test-hugo -- --compare-snapshot <true|false>
Overview
The following validations will run on npm run test-hugo
:
- Run
htmlproofer
onpublic
directory- Add
--htmlproofer false
to skip this steps
- Add
- Compared recorded snapshots to correcting files under
public
directory- Add
--compare-snapshot false
to skip this step
- Add
To add or update snapshots: npm run test-hugo -- --add-snapshot <PATH>
This tool is configurable by setting appropriate entries in package.json
file. Example:
"test-hugo": {
"options": "-D", # Hugo CLI's options
"diff": "--brief -b", # diff's option
"snapshotFailfast": false # Stop comparing at first mismatch?
"htmlproofer": "/usr/local/lib/ruby/gems/2.6.0/bin/htmlproofer" # default is htmlproofer, set this option if you need to specify a path
}
Sample project
See the huwent
hugo site inside test
folder
External Dependencies
- htmlproofer: requires Ruby
License
MIT