Skip to content

About

Cucumber step definitions for static sites built with Jekyll, for webship-js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

jekyll-steps

Jekyll logo: this pack supports Jekyll

Cucumber step definitions for static sites built with Jekyll, for webship-js, a BDD browser automation harness built on Playwright and Cucumber-js.

A Jekyll site is made of the same parts again and again: posts listed newest first and paged by a paginator, drafts, future posts and unpublished posts that must stay off the site, an Atom feed, a sitemap, the url of _config.yml that every absolute address carries, and the search-engine data of jekyll-seo-tag. The steps check those parts, so a scenario reads the same for any Jekyll site:

  • the listing: the posts a page lists and their order, the pager to older and newer posts and its "page n of m", the number of posts the whole listing holds, a post opened from the listing and its date;
  • what is published: a published post at its address, in the listing and in the feed; a draft, a post dated in the future or a post with published: false nowhere (not at its address, not in any page of the listing, not in the feed, not in the sitemap);
  • the feed and the sitemap: the posts the feed holds, the addresses the sitemap lists or leaves out, and the check that both carry the site's own address;
  • search-engine data: a page's own canonical address and its structured data (JSON-LD) type;
  • the site as a whole: a crawl that checks that every internal link answers 200 (capped in pages and in time, skipping off-site and fragment-only links), no request outside the site's address, and its not-found page.

A static site has no users and no secrets: no step signs in, and no step needs anything but the site's address.

No step phrase names the platform: a scenario reads Then the static site should not publish the draft "…" and When I follow the static site's pager to older posts.

Requirements

  • Node.js 24 or newer.
  • webship-js 2.0.20 or newer.
  • A site built with Jekyll and served as static files (nginx, Apache, jekyll serve). Jekyll 4.4.1 and 4.3.4 are the two lines this pack is proven on, on Ruby 3.4.13; its CI also runs 4.4.1 on Ruby 4.0.10.
  • For the feed and the sitemap steps, the jekyll-feed and jekyll-sitemap plugins (or a feed and a sitemap of the same shape at the paths you set); for the canonical address and structured data, jekyll-seo-tag.

Jekyll's releases

Jekyll's last release is 4.4.1, of 2025-01-29; there has been none since. The repository is maintained: it has commits up to 2026-10. This pack covers the two lines in use, 4.4.1 and 4.3.4.

Jekyll 4.3 on Ruby 3.4: add csv and base64

Ruby 3.4 no longer ships csv and base64 as default gems. Jekyll 4.3.4 loads csv itself, and its safe_yaml dependency loads base64, so on Ruby 3.4 a 4.3.4 site stops at its first build with cannot load such file -- csv (then -- base64). Add both to the site's Gemfile:

gem "csv"
gem "base64"

Jekyll 4.4 declares what it needs and builds on Ruby 3.4 and 4.0 without them; the demo adds them on both lines, which does no harm on 4.4.

Install

npm install --save-dev @webship-js/jekyll-steps

List its step definitions in cucumber.js, after webship-js's own, and point the suite at the site:

require: [
  'node_modules/webship-js/tests/step-definitions/**/*.js',
  'node_modules/@webship-js/jekyll-steps/tests/step-definitions/**/*.js',
  'tests/step-definitions/**/*.js',
],
worldParameters: {
  launchUrl: 'https://notes.ddev.site',
  staticSite: {
    feed: '/feed.xml',
    sitemap: '/sitemap.xml',
    crawl: { maxPages: 200, seconds: 120 },
    selectors: {},           // minima's markup by default; see Settings
  },
},

Quick start

Feature: What the notes site publishes

  Scenario: The listing, a post and what stays off the site
    Given I am on the homepage
    Then the static site should list the posts "The first gale", "The swifts leave" and "A spring tide" in this order
    And the static site's pager should say page 1 of 2
    When I follow the static site's pager to older posts
    And I open the static site post "The first frost"
    Then the static site post should be dated "2026-01-14"
    And the static site should not publish the draft "A draft about the heron"
    And the static site should not publish the post "A note kept back" at "/2026/11/05/a-note-kept-back/"
    And the static site's feed and sitemap should use the site's own address
    And every internal link of the static site should answer 200, skipping off-site and fragment-only links
npx cucumber-js

From nothing to a green run

git clone https://github.com/webship/jekyll-steps.git && cd jekyll-steps
npm ci && npx playwright install chromium
bash .github/scripts/build-demo.sh 4.4.1      # the demo site at http://127.0.0.1:8781 (4.3.4: 8782)
npx cucumber-js                               # the suite
npm run test:must-fail                        # the assertions that must fail
bash .github/scripts/remove-demo.sh 4.4.1 --image

DEMO_RUBY=4.0 bash .github/scripts/build-demo.sh 4.4.1 builds the demo on Ruby 4.0.10 instead.

The demo site

demo/jekyll-demo-site.sh makes a site of our own at build time (nothing of it ships in the package): jekyll new with its default theme, minima 2.5.2, then made-up notes of a made-up field station:

  • five published posts of 2026, three to a page (jekyll-paginate), with our own home page that draws the pager (minima 2.5's home layout lists every post and ignores the paginator);
  • a draft (_drafts/), a post dated 2099 and a post with published: false: none of them may be on the site;
  • an about page, our own not-found page, our own small icon at /favicon.ico (so no page logs a 404 for it), an Atom feed, a sitemap, jekyll-seo-tag's data;
  • two check pages for the assertions that must fail, linked from nowhere and left out of the sitemap: /checks/broken-link/ (a link to an address the site does not have) and /checks/outside-request/ (a picture asked of a closed port of this machine; the request never leaves it).

minima 2.5.2 asks for no web font and no outside asset, and the demo draws no social links, so its pages ask no other address.

demo/Dockerfile builds it in two stages on the official Ruby image by its digest: the first has the build tools the gems need (eventmachine and http_parser.rb compile), the second only the site and its compiled gems. The demo builds the site at start for the address it is served at (SITE_URL) and serves it with jekyll serve --no-watch, capped at 256 MB, with no capabilities.

What the suite tests

9 scenarios in tests/features/: the listing and its pager, a post opened from it, the published posts, the draft, future and unpublished posts, the feed and the sitemap and the address they carry, a page's canonical address, description and structured data, the crawl, the outside requests and the not-found page. Run twice, it passes twice: it only reads the site.

Settings

All in worldParameters.staticSite of cucumber.js:

Setting Default What it is
feed /feed.xml The path of the Atom feed (jekyll-feed's).
sitemap /sitemap.xml The path of the sitemap (jekyll-sitemap's).
crawl.maxPages 200 The crawl reads at most this many HTML pages.
crawl.seconds 120 The crawl stops after this many seconds.
selectors.postLink .post-list a.post-link A post's link in a listing.
selectors.pager nav.pager, .pagination, .pager The pager of a paginated listing.
selectors.older a[rel="next"] The pager's link to older posts.
selectors.newer a[rel="prev"] The pager's link to newer posts.
selectors.postDate meta[property="article:published_time"], article time[datetime], time[datetime] A post's date.

The selectors are minima's, and those of a paginated home page that sets rel on its pager's links. A site of another theme sets its own.

Steps

jekyll-listing.steps.js (6)

  • Then the static site should list the posts "A", "B" and "C" in this order
  • When I follow the static site's pager to older posts / newer posts
  • Then the static site's pager should say page 1 of 2
  • Then the static site should list 5 posts in all
  • When I open the static site post "The first frost"
  • Then the static site post should be dated "2026-01-14"

jekyll-publishing.steps.js (2)

  • Then the static site should not publish the post|draft|future post "…" (optionally at "/path/")
  • Then the static site should publish the post "…" at "/path/"

jekyll-feeds.steps.js (5)

  • Then the static site's feed should list the posts "A" and "B" in this order
  • Then the static site's sitemap should list the address "/about/" / should not list
  • Then the static site's feed and sitemap should use the site's own address
  • Then the static site page should have its own canonical address
  • Then the static site post should carry structured data of type "BlogPosting"

A page's description is webship-js's own step: Then the meta tag should exist with the following attributes:.

jekyll-health.steps.js (3)

  • Then every internal link of the static site should answer 200, skipping off-site and fragment-only links
  • Then the static site should make no outside requests
  • Then a missing static site address should answer 404 with the page "Page not found"

Each step's JSDoc in tests/step-definitions/ gives five examples of its phrasing.

What "every internal link" means

The crawl starts at the home page, the page the browser is on, and the feed and the sitemap when the site has them (one it does not have is no broken link, unless a page links to it). It requests every address on the site's own address that their pages carry (the href and src of a, link, script, img, source, iframe and area, and the first address of each srcset), and reads each HTML page it reaches for more. Each must answer 200, after redirects. It does not follow, and counts in the report:

  • off-site links, to another address: whether a page asks another site is the outside-request step's job;
  • fragment-only links (#top): they are the page itself;
  • mailto:, tel:, javascript: and data: links.

It reads at most crawl.maxPages pages (200) in at most crawl.seconds (120). When a cap is reached, the report says how many addresses were left unchecked; the step fails only on a link that does not answer 200, and names the page it was found on.

What a run leaves behind

The reports in tests/reports/, and a screenshot of a failed step in screenshots/. The suite changes nothing on the site.

Licence of the framework

Jekyll is free software under the MIT licence. This pack only reads the sites it builds.

Phrases shared with other packs

None: every step names "the static site", and none of the 78 webship-js packs checked shares a phrase with this one.

Testing this package

npm run test:examples     # each step's five examples match its own definition only
npm run test:paths        # a feature named on the command line runs alone
npx cucumber-js --dry-run # no undefined or ambiguous step
npx cucumber-js           # the suite (the demo up)
npm run test:must-fail    # 19 assertions that must fail, each with its message and a hint

CI runs all of them on Jekyll 4.4.1 and 4.3.4 on Ruby 3.4.13, and on Jekyll 4.4.1 on Ruby 4.0.10.

License

MIT. See LICENSE.

Logo

The logo is Simple Icons' Jekyll icon (icons/jekyll.svg of simple-icons 16.39.0), in the colour the set lists for it (#CC0000); its path is unmodified. Simple Icons takes it from Jekyll's brand repository (github.com/jekyll/brand), whose logo files are licensed under the Creative Commons Attribution 4.0 International License: the Jekyll logo by the Jekyll project, CC BY 4.0; the colour is set on the path, nothing else is changed. It is not covered by this package's licence.


Jekyll and the Jekyll logo belong to the Jekyll project. This project is not endorsed by or affiliated with Jekyll or its maintainers.

About

Cucumber step definitions for static sites built with Jekyll, for webship-js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages