-
Notifications
You must be signed in to change notification settings - Fork 22
Auth and Users
By default there are five users generated one for each default user role:
-
Username:
admin
-
Password:
password
-
Username:
editor
-
Password:
password
-
Username:
author
-
Password:
password
-
Username:
contributor
-
Password:
password
-
Username:
subscriber
-
Password:
password
To save time on tests and so you don't have to perform any login/authentification logic, by default login will be bypassed with wp-cypress
and the user will be logged in as the admin user. If you wish to change user you can use the cypress command cy.switchUser('<username>', '<password>')
to programatically switch users at specific points during your test.
You can generate other users when seeding your database with test data. You can make use of the existing User fixture or perform any custom logic that may required.
An example of using a fixture:
To learn more about using a seed see Seeds and Fixtures
public function run() {
$user = new Fixtures\User( [
'role' => 'admin',
'user_login' => 'exampleuser',
'user_pass' => 'password123',
'display_name' => $this->faker->name(),
'first_name' => $this->faker->firstName(),
] );
$user->create( 1 );
}
Then to log in as this user in your cypress tests you can use the switchUser
command:
cy.switchUser('exampleuser', 'password123');