1.1.5 • Published 1 month ago

cypress-wordpress-session v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

cypress-wordpress-session

This module can be used to restore a Wordpress session in Cypress by automatically saving Wordpress login cookies to a file.

By default, it'll save the cookies to an invisible JSON file with path .wordpress-login-cookies.json. Only relevant cookie data will be saved. If you're using git, it'd probably be a good idea to add this path to your .gitignore file for security reasons!

If the file exists, this module will access it to restore your session. If the file doesn't exist or the cookie is invalid, it will attempt to login from scratch.

If you've already configured your Cypress project to navigate to Wordpress, you just need to import this module, supply login credentials and it'll handle the rest for you.

Multiple users and domains are supported! Provided the login cookies are still valid, you can use this module to switch users between tests (or even within the same test) without going back to the login screen.

For example:

import "cypress-wordpress-session";

const username = "admin";
const password = "123";

const options = {};

describe("Admin: article", () => {
  beforeEach(() => {
    cy.wordpressSession(username, password, options);
  });

  it("does something in wordpress", () => {
    // test code here
  });
});

The only required parameters are username and password.

Parameters

NameTypeDefault valueDescription
usernamestringundefinedWordpress username
passwordstringundefinedWordpress password
optionsobjectsee table belowVarious options, see table below

Options

NameTypeDefault valueDescription
cookiesFilepathstring.wordpress-login-cookies.jsonThe location at which the cookies are saved & restored
verboseLoggingbooleanfalseEnable verbose logging
landingPagestring/wp-adminThe page to land on once logged in or once the session has been restored. Can be set to a falsy value to prevent this.
obscurePasswordbooleantrueHide the password from the session parameters, thus preventing it from being easily viewable in the Cypress GUI
sessionOptionsobject{ cacheAcrossSpecs: true }Cypress session options (see Cypress docs)
1.1.5

1 month ago

1.1.4

1 month ago

1.1.3

2 months ago

1.1.2

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.0

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago