Overview
NestJS 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/nestjs-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/nestjs-steps/tests/step-definitions/*.js',
'tests/step-definitions/**/*.js',
]
Test users
The steps that log in use accounts that already exist on the site, by the handle a feature names (Given I am a logged in user with the "admin" user). The site build creates them; a feature never creates or deletes an account. They are listed in cucumber.js under worldParameters. These are the test accounts of the pack's own test site: put the accounts of your site in your project, and keep real passwords in environment variables.
{
"worldParameters": {
"users": {
"admin": {
"username": "admin"
},
"editor": {
"username": "editor"
}
}
}
}
Steps
- Given I am signed in to the backend as "admin"
- Given I am signed out of the backend
- Then the backend should have refused me as not signed in
- Then the backend should document "POST /v1/products" as needing a sign-in
- When I sign out of the backend's docs
- Then the backend should have accepted the request
- Then the backend should have refused "price" with "must not be less than 0"
- Then the backend should have answered 404 with "Product 99 not found"
- Then the backend should have found no route for the request
- Then the backend should be healthy
- Then the backend's "memory_heap" check should be "up"
- Then the backend should document "POST /v1/products"
- Then the backend should document "POST /v1/products" with the required fields "name, price"
- Then the backend's answer should match its documented schema
- When I open the backend's docs
- Then the backend's docs should list "POST /v1/products"
- When I authorize the backend's docs as "editor"
- When I try out "GET /v1/products" in the backend's docs
- When I try out "POST /v1/products" in the backend's docs with:
- Then the backend's docs should show the answer 200
- When I save the "id" of the backend's docs' answer as placeholder "{{product}}"
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/nestjs-steps.
Logo
The logo is Simple Icons' NestJS icon (icons/nestjs.svg of simple-icons 16.37.0, CC0-1.0), in the colour the set lists for the brand; its path is unmodified. NestJS and its mark are its authors': the logo names the framework the pack tests. It is not covered by this package's licence.