How to easily test generated static site content?

I’m generating a static site using Jekyll, and I’d like to run a few smoke tests on the resulting HTML before publishing, such as an article page having the appropriate “Article Title — Site Name” title.

The tests do not require CSS or JavaScript support, so I don’t need a complete browser.

Some people seem to recommend RSpec + Capybara, but it looks like Capybara isn’t in nixpkgs, and packaging a bunch of stuff seems like a lot of work for such a simple site. I’m not too fussed about the test suite being Ruby-based, although it might be helpful since Jekyll is Ruby. Any suggestions?

Update: HTMLProofer can do at least part of the job (except for verifying specific content), and it happens to be in Ruby. Nice!

1 Like

Might not fit your use case but the other thing that can be handy with static sites is to keep a copy the previous build and recursive diff against it before publishing to catch any unexpected changes.

It’s simple and DIY-style, but you could use hred to extract specific content for testing purposes. It’s not packaged in nixpkgs, but node2nix handles it with zero tweaks.

That’s a really useful test, but over the budget for a personal blog. A thorough review of each diff takes a long time, and subtle errors can easily creep as part of bigger changes.