Overview
Gatsby Steps adds step definitions to Webship-js 2.0.x for the markup the platform itself renders, regardless of theme or distribution, so scenarios read as plain sentences instead of CSS selectors. It is a plugin for Webship-js: it ships one file of step definitions you drop into an existing test project, and it composes with the built-in steps rather than duplicating them.
Install
npm install --save-dev @webship-js/gatsby-steps
Then add its step file to cucumber.js beside the Webship-js steps:
require: [
'node_modules/webship-js/tests/step-definitions/**/*.js',
'node_modules/@webship-js/gatsby-steps/tests/step-definitions/*.js',
'tests/step-definitions/**/*.js',
]
Steps
- Then I should see an optimized image
- Then the optimized image should be loaded
- Then the optimized image should offer the "avif" format
- Then the optimized image should have a placeholder
- Then the page-data for "/" should be available
- Then the 404 page should be available
- Then I should be on a 404 page
- Then I should be on the default 404 page
- Then the page title should be "Home | Gatsby Default Starter"
- When I click the link "Page 2" without a full page reload
- When I go back without a full page reload
- Then the page should have a route announcer
- Then the route announcer should announce "Hi from the second page"
- Then the page "/page-2/" should be prefetched
- Then the scroll position should be restored
- Then the page generator should start with "Gatsby"
- Then the page generator version should start with "5"
- Then the site should be a production build
- Then I should see a hydrated page
- Then there should be no hydration errors
- Then the page should be from the current build
- Then the page head should be set by the Head API
- Then the web app manifest should be valid
- Then I should see "Welcome to Gatsby!" without JavaScript
Every assertion step reads both polarities from one definition: should see and should not see are the same step. Source and issues: github.com/webship/gatsby-steps.