Overview
CodeIgniter 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/codeigniter-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/codeigniter-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": {
"email": "admin@example.com",
"username": "admin",
"password": "Account-Pass-2026!"
},
"developer": {
"email": "developer@example.com",
"username": "developer",
"password": "Account-Pass-2026!"
},
"user": {
"email": "user@example.com",
"username": "user",
"password": "Account-Pass-2026!"
},
"banned": {
"email": "banned@example.com",
"username": "banned",
"password": "Account-Pass-2026!"
}
}
}
}
Steps
- Given I am a logged in user with the "admin" user
- When I log in as "user" with the login form
- When I log in with the email "user@example.com" and the password "wrong-password"
- When a page of another site sends the login form of "user" to "/login"
- When I log out
- Then I should be logged in
- Then I should be logged in as "user"
- Then I should see the login form
- When my session expires
- When I ask for a login link for "user"
- Then I should have access to "/admin"
- Then the access to "/admin" should be:
- When I fill in "Password" with the password of "user"
- Then the "Email Address" field should hold the email of "user"
- Then I should see the error message "Unable to log you in. Please check your password."
- Then I should not see any error message
- Then the "Username" field should block submission as required
- When the security token of the form expires
- Then an email with the subject "Your Login Link" should be sent to "user"
- Then no email should be sent to "nobody@example.com"
- Then the email with the subject "Your Login Link" to "user" should contain "Username: user"
- When I open the "Login" link of the email to "user"
- Then I should see the 404 error page
- Then the page should not show debug information
- Then I should see the welcome page
- Then the page should say it runs in the "production" environment
- Then I should see the debug toolbar
- When I open the "Routes" panel of the debug toolbar
- Then the "Routes" panel of the debug toolbar should show "TestFixtures::account"
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/codeigniter-steps.